Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Linear regression TF2 update params
def update(self, X, y, learning_rate):
with tf.GradientTape(persistent=True) as g:
loss = self.mse(y, self.predict(X))
print("Loss: ", loss)
dy_dm = g.gradient(loss, self.m)
dy_db = g.gradient(loss, self.b)
self.m.assign_sub(learning_rate * dy_dm)
self.b.assign_sub(learning_rate * dy_db)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.