tensorflow/model-optimization

Unsupported operations when applying tfmot

Opened this issue · 1 comments

Hi, I'm trying to apply tfmot for an implementation of BiSeNetV2, when executing tfmot.quantization.keras.quantize_model, I meet errors with the following operations:

tf.reduce_mean: Layer tf.math.reduce_mean:<class 'tensorflow.python.keras.layers.core.TFOpLambda'> is not supported. You can quantize this layer by passing a tfmot.quantization.keras.QuantizeConfig instance to the quantize_annotate_layer API.
tf.nn.sigmoid: Exception has occurred: RuntimeError
Layer tf.math.sigmoid_1:<class 'tensorflow.python.keras.layers.core.TFOpLambda'> is not supported. You can quantize this layer by passing a tfmot.quantization.keras.QuantizeConfig instance to the quantize_annotate_layer API.

tf.image.resize: Exception has occurred: ValueError 'images' must have either 3 or 4 dimensions.

  1. For layer tf.reduce_mean and tf.nn.sigmoid, the class is tensorflow.python.keras.layers.core.TFOpLambda, and they are failed to be executed with tfmot.quantization.keras.QuantizeConfig. How to apply these layers to tfmot?
  2. How to effectively apply tf.image.resize to tfmot model?

The followings are the settings of TensorFlow:
TensorFlow-gpu 2.4.0
tensorflow-model-optimization 0.7.1

Best Regards,
Rahn

@Xhark Could you take a look.