Base class for Keras optimizers.

You should not use this class directly, but instead instantiate one of its subclasses such as tf.keras.optimizers.SGD, tf.keras.optimizers.Adam, etc.


# Create an optimizer with the desired parameters.
opt = tf.keras.optimizers.SGD(learning_rate=0.1)
# `loss` is a callable that takes no argument and returns the value
# to minimize.
loss = lambda: 3 * var1 * var1 + 2 * var2 * var2
# In graph mode, returns op that minimizes the loss by updating the listed
# variables.
opt_op = opt.minimize(loss, var_list=[var1, var2])
# In eager mode, simply call minimize to update the list of variables.
opt.minimize(loss, var_list=[var1, var2])

Usage in custom training loops

In Keras m