StevenBanama / C3AE

C3AE implement
BSD 2-Clause "Simplified" License
87 stars 16 forks source link

the error of "call() got an unexpected keyword argument 'training'",when convert to tflite #31

Open xieshenru opened 3 years ago

xieshenru commented 3 years ago

when convert to tflite,the error of "call() got an unexpected keyword argument 'training'" appear,how to resolve it?

import tensorflow as tf import keras from keras.layers import BatchNormalization, ReLU from keras.backend import pool2d from utils import focal_loss

modelpath = r'./model/c3ae_model_v2.h5' model = keras.models.load_model(modelpath, custom_objects={"pool2d": pool2d, "ReLU": ReLU, "BatchNormalization": BatchNormalization, "tf": tf, "focal_loss_fixed": focal_loss([1] * 12)}) converter = tf.lite.TFLiteConverter.from_keras_model(model)

tflite_model = converter.convert() savepath = r'./model.tflite' open(savepath, "wb").write(tflite_model) the above is the code I used,how to resolve this error?

StevenBanama commented 3 years ago

keras not test yet! you should use tf. keras, which tf=2.1