Join us at TensorFlow World, Oct 28-31. Use code TF20 for 20% off select passes. Register now

tfmot.sparsity.keras.prune_scope

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

tfmot.sparsity.keras.prune_scope()

Defined in python/core/sparsity/keras/prune.py.

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

Returns:

Object of type `CustomObjectScope` with pruning objects included.

Example:

pruned_model = prune_low_magnitude(model, **self.params)
keras.models.save_model(pruned_model, keras_file)

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