# tf.keras.optimizers.serialize

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/keras-team/keras/tree/v2.13.1/keras/optimizers/__init__.py#L73-L91) |

Serialize the optimizer configuration to JSON compatible python dict.

#### View aliases


**Main aliases**

[`tf.optimizers.serialize`](https://www.tensorflow.org/api_docs/python/tf/keras/optimizers/serialize)
**Compat aliases for migration**

See
[Migration guide](https://www.tensorflow.org/guide/migrate) for
more details.

\`tf.compat.v1.keras.optimizers.serialize\`

<br />

    tf.keras.optimizers.serialize(
        optimizer, use_legacy_format=False
    )

The configuration can be used for persistence and reconstruct the
`Optimizer` instance again.

    tf.keras.optimizers.serialize(tf.keras.optimizers.legacy.SGD())
    {'module': 'keras.optimizers.legacy', 'class_name': 'SGD', 'config': {'name': 'SGD', 'learning_rate': 0.01, 'decay': 0.0, 'momentum': 0.0, 'nesterov': False}, 'registered_name': None}