From 5591008d0f9c037156c7721d0874ee95d45a7196 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Rothenh=C3=A4usler?= <80271074+miker2241@users.noreply.github.com> Date: Wed, 29 Jun 2022 14:50:17 +0200 Subject: [PATCH] Add variable definitions to usage example --- keras/optimizers/optimizer_v2/optimizer_v2.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/keras/optimizers/optimizer_v2/optimizer_v2.py b/keras/optimizers/optimizer_v2/optimizer_v2.py index 70be00bb4bd..88383657542 100644 --- a/keras/optimizers/optimizer_v2/optimizer_v2.py +++ b/keras/optimizers/optimizer_v2/optimizer_v2.py @@ -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.