File "/home/modelparser/Conformer/conformer_tf/conformer_tf.py", line 168, in call
inputs = self.conv(inputs) + inputs
File "/home/modelparser/Conformer/conformer_tf/conformer_tf.py", line 128, in call
return self.net(inputs)
File "/home/modelparser/Conformer/conformer_tf/conformer_tf.py", line 89, in call
return tf.keras.layers.BatchNormalization(axis=-1)(inputs)
ValueError: Exception encountered when calling layer 'batch_norm' (type BatchNorm).
tf.function only supports singleton tf.Variables created on the first call. Make sure the tf.Variable is only created once or created outside tf.function. See https://www.tensorflow.org/guide/function#creating_tfvariables for more information.
Call arguments received by layer 'batch_norm' (type BatchNorm):
• inputs=tf.Tensor(shape=(1, 1024, 1024), dtype=float32)
when i tried to convert .h5 to .tflite using convformer block, i got the above message.
it caused by BatchNorm class.
i fix BatchNorm class like this. and fixed it.
class BatchNorm(tf.keras.layers.Layer):
def __init__(self, causal, **kwargs):
super(BatchNorm, self).__init__(**kwargs)
self.causal = causal
self.bnorm = tf.keras.layers.BatchNormalization(axis=-1)
def call(self, inputs):
if not self.causal:
return self.bnorm(inputs)
return tf.identity(inputs)
To Reproduce
I referred to tflite code in official site
Describe the bug
when i tried to convert .h5 to .tflite using convformer block, i got the above message. it caused by BatchNorm class. i fix BatchNorm class like this. and fixed it.
To Reproduce I referred to tflite code in official site
Desktop (please complete the following information):
Smartphone (please complete the following information):
Additional context