Skip to content

Instantly share code, notes, and snippets.

@dvgodoy
Created July 13, 2020 18:54
Show Gist options
  • Save dvgodoy/6ac4841970378da8d63fc6c7590be886 to your computer and use it in GitHub Desktop.
Save dvgodoy/6ac4841970378da8d63fc6c7590be886 to your computer and use it in GitHub Desktop.
# Computes our model's predicted output - forward pass
yhat = b + w * x_train
# Computing the loss
# We are using ALL data points, so this is BATCH gradient
# descent. How wrong is our model? That's the error!
error = (yhat - y_train)
# It is a regression, so it computes mean squared error (MSE)
loss = (error ** 2).mean()
print(loss)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment