tflite: Converting unsupported operation: AddV2 FusedBatchNormV3

所用的conda环境下tensorflow = 1.15.3

测试代码如下:

import tensorflow as tf

tflite_path = 'test.tflite'
keras_path = 'test.h5'

bn = tf.keras.layers.BatchNormalization(
    # fused=False,
    input_shape = (128,128,3)
)

# Create model
k_model = tf.keras.models.Sequential()
k_model.add(bn)
k_model.save(keras_path)

# Convert keras model to tflite
converter = tf.lite.TFLiteConverter.from_keras_model_file(keras_path)
converter.experimental_new_converter = True
tflite_model = converter.convert()
open(tflite_path, 'wb').write(tflite_model)

会报Converting unsupported operation: FusedBatchNormV3

ADDv2同理

-------------------------------

查找了一天,最后发现原因是本机环境上安装了早期的tensorflow版本1.13.1 ,导致toco一直用的是1.13的版本

用pip uninstall卸载本机的tensorlfow

(windows用户检查下AppData/Roaming/Python里还有没有

 ubuntu检查home bin里)

然后卸载conda环境下的tensorlfow,再重新安装,可以看到toco安装信息:

再次测试,完成!

忠告:请在虚拟环境下开发!!不然版本冲突搞死人

猜你喜欢

转载自blog.csdn.net/yxpandjay/article/details/108752852