I am building a functional Keras model using TensorFlow version 2.9.1, and attempting to use tensorflow-model-optimization
to apply pruning. Specifically, the model is YOLOv5’s Keras variant with the layers modified to be PrunableLayer
instances.
The model is constructed in a functional manner as can be seen here: yolov5/export.py at master · ultralytics/yolov5 · GitHub
However, when attempting to apply pruning, this error is produced: prune_low_magnitude can only prune an object of the following types: tf.keras.models.Sequential, tf.keras functional model, tf.keras.layers.Layer, list of tf.keras.layers.Layer. You passed an object of type: Model.
Why is my model not qualifying as a functional Keras model for this purpose? Are there particular additional requirements for it to qualify?