Missed TensorFlow World? Check out the recap. Learn more

tfmot.sparsity.keras.prune_scope

View source on GitHub

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

tfmot.sparsity.keras.prune_scope()

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)