Open Janus-Shiau opened 1 year ago
Hi!
I'm also suffering from the same error using tf.split
Is there any fix coming soon?
Hi, I'm getting the same error too with tf.transpose and tf.permute, any update on a solution?
Hi, tf.nn.depthtospace causes the same error. I'd be very happy about any advice how to solve this :)
I think I had the same issue.
I could overcome this error by wrapping tf.split()
in a keras layer:
@keras.saving.register_keras_serializable(package="MyLayers", name="SplitLayer")
class SplitLayer(keras.layers.Layer):
def __init__(self, num_or_size_splits, axis, **kwargs):
super(SplitLayer, self).__init__(**kwargs)
self.num_or_size_splits = num_or_size_splits
self.axis = axis
def call(self, inputs):
return tf.split(inputs, self.num_or_size_splits, axis=self.axis)
def get_config(self):
config = super(SplitLayer, self).get_config()
config.update({
'num_or_size_splits': self.num_or_size_splits,
'axis': self.axis,
})
return config
I quantized my model (RetinaNet) like this:
def quantize_model(model):
def quantize_annotate(layer):
layer_types_to_avoid = (kcv.layers.AnchorGenerator, kcv.models.retinanet.LabelEncoder, kcv.layers.NonMaxSuppression, my_retinanet.MyPredictionDecoder)
if isinstance(layer, layer_types_to_avoid) or "split" in layer.name:
return layer
return tfmot.quantization.keras.quantize_annotate_layer(layer)
annotated_model = tf.keras.models.clone_model(
model,
clone_function=quantize_annotate,
)
with tfmot.quantization.keras.quantize_scope():
quantized_model = tfmot.quantization.keras.quantize_apply(annotated_model)
return quantized_model
tf version: 2.15.1 keras version: 2.15.0 tfmot version: 0.7.5
Describe the bug
We are trying to implement some network like ShuffleNetV2 but encounter some error when
quantize_apply
the model.I believe ShuffleNet or related ideas are popular in edge devices, please kindly help us to resolve this proble.
Any advice is welcome.
System information
TensorFlow version (installed from source or binary): 2.7.0
TensorFlow Model Optimization version (installed from source or binary): 0.7.0
Python version: 3.8.13
Describe the expected behavior
Just add quantization-aware operator in to the model.
Describe the current behavior
When running the provided code, either the
tf.transpose
ortf.split
will cause error to Tensorflow Model Optimization.The error message due to
tf.split
before convolution layers:The error message due to
tf.transpose
:Code to reproduce the issue
Just run the following code you will get the error message due to
tf.split
.You can just comment the following three lines of code will get the error message from
tf.transpose
.