Skip to content

Commit

Permalink
Add variable definitions to usage example
Browse files Browse the repository at this point in the history
  • Loading branch information
miker2241 authored Jun 29, 2022
1 parent 07e1374 commit 766dc1f
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 @@ -108,6 +108,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 766dc1f

Please sign in to comment.