Skip to content

Make Pruning TF 2.X Ready #172

@alanchiao

Description

@alanchiao

Subsequently update https://www.tensorflow.org/model_optimization/guide/pruning to indicate compatibility.

Progress: submitted commits that are relevant:

As a byproduct of this (by updating calls to TF to tf. instead of from ... import), we will also:

  • ensure we don't mix 1.X and 2.X behavior (we currently do)
  • prevent end user breakages when using the pip package
    • For instance, we used the tf.keras.experimental.load_saved_model and tf.keras.experimental.save_saved_model APIs, but the path switched from "from tensorflow.python.keras.saving import saved_model" to "from tensorflow.python.keras.saving import saved_model_experimental", making the code no longer compatible with older TF releases. By switching to just "tf.keras.experimental.load_saved_model", this would have been prevented. This can happen in general since TF doesn't guarantee the file paths don't change, only the public APIs won't change.
  • improve maintainability

Remaining issues:

  • Consider use case of loading 1.X model into 2.X code.
  • Consider case of importing SavedModel. Our whitelist doesn't include the SavedModel versions of the layers. E.g. "<class 'tensorflow.python.keras.saving.saved_model.load.ZeroPadding2D'>" isn't the same as tf.keras.layers.ZeroPadding2D. Note that SavedModel no longer uses its versions of the layers, as of TF nightly due to tensorflow/tensorflow@568427a

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions