Skip to content

Commit

Permalink
Merge pull request #16731 from miker2241:patch-add-variable-definitions
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 458500460
  • Loading branch information
tensorflower-gardener committed Jul 1, 2022
2 parents cc28c7d + 5591008 commit 7dd01b1
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions keras/optimizers/optimizer_v2/optimizer_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ class OptimizerV2(tf.__internal__.tracking.Trackable):
opt = tf.keras.optimizers.SGD(learning_rate=0.1)
# `loss` is a callable that takes no argument and returns the value
# to minimize.
var1 = tf.Variable(2.0)
var2 = tf.Variable(5.0)
loss = lambda: 3 * var1 * var1 + 2 * var2 * var2
# In graph mode, returns op that minimizes the loss by updating the listed
# variables.
Expand Down

0 comments on commit 7dd01b1

Please sign in to comment.