tfmot.clustering.keras.cluster_scope

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

Used in the notebooks

Used in the guide

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

Object of type CustomObjectScope with clustering objects included.

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)