Skip to content

Instantly share code, notes, and snippets.

@tarunlnmiit
Created August 18, 2020 19:18
Show Gist options
  • Save tarunlnmiit/75902865526a5b01914d5404353424d1 to your computer and use it in GitHub Desktop.
Save tarunlnmiit/75902865526a5b01914d5404353424d1 to your computer and use it in GitHub Desktop.
def calculateGradient(W, X, Y, f_x, learningRate):
gradient = (Y - f_x) * X
gradient = np.sum(gradient, axis=0)
# gradient = np.array([float("{0:.4f}".format(val)) for val in gradient])
temp = np.array(learningRate * gradient).reshape(W.shape)
W = W + temp
return gradient, W.astype(float)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment