<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/model-optimization/blob/v0.8.1/tensorflow_model_optimization/python/core/clustering/keras/cluster.py#L34-L53) |

Provides a scope in which Clustered layers and models can be deserialized.

    tfmot.clustering.keras.cluster_scope()

### Used in the notebooks

| Used in the guide |
|---|
| - [Weight clustering comprehensive guide](https://www.tensorflow.org/model_optimization/guide/clustering/clustering_comprehensive_guide) |

If a keras model or layer has been clustered, it needs to be within this scope
to be successfully deserialized.

<br />

<br />

<br />

| ## Returns ||
|---|---|
| Object of type `CustomObjectScope` with clustering objects included. ||

<br />

#### Example:

    clustered_model = cluster_weights(model, **self.params)
    keras.models.save_model(clustered_model, keras_file)

    with cluster_scope():
      loaded_model = keras.models.load_model(keras_file)