# tf.keras.layers.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/layers/serialization.py#L191-L222) |

Serializes a `Layer` object into a JSON-compatible representation.

#### View aliases


**Compat aliases for migration**

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

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

<br />

    tf.keras.layers.serialize(
        layer, use_legacy_format=False
    )

<br />

<br />

<br />

| ## Args ||
|---|---|
| `layer` | The `Layer` object to serialize. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| A JSON-serializable dict representing the object's config. ||

<br />

#### Example:

    from pprint import pprint
    model = tf.keras.models.Sequential()
    model.add(tf.keras.Input(shape=(16,)))
    model.add(tf.keras.layers.Dense(32, activation='relu'))

    pprint(tf.keras.layers.serialize(model))
    # prints the configuration of the model, as a dict.