“顺序”对象没有属性“_get_save_spec”
import tensorflow as tf
import coremltools as ct
print(tf.__version__)
# Load your existing Keras model
model_path = "/Users/name/Desktop/model.h5"
model = tf.keras.models.load_model(model_path)
# Save the model in SavedModel format
model.save(model_path, save_format='tensorflow')
# Convert the SavedModel to CoreML, specifying the source as 'tensorflow'
coreml_model = ct.convert(model_path, source='tensorflow')
# Save the CoreML model
coreml_model.save("/Users/name/Desktop/model.mlmodel")
我被告知要降级版本,我一直降级到 TensorFlow 2.13.0。任何指导表示赞赏。
保存前只需运行一次 model.predict() 即可。 coremltools 文档中给出了这一点。