【发布时间】:2020-05-04 23:18:30
【问题描述】:
嘿,我正在尝试将我的 Keras 模型转换为 CoreML,但我不断收到此错误:
tensorflow.python.framework.errors_impl.OperatorNotAllowedInGraphError: using a tf.Tensor as
a Python bool is not allowed in Graph execution. Use Eager execution or decorate this
function with @tf.function.
这是我的代码:
import keras
import coremltools
import tensorflow as tf
model = keras.models.load_model('machine.h5')
print(model.input)
print(model.input_shape)
print(model.output)
model= coremltools.converters.keras.convert(
'machine.h5', input_name_shape_dict={'embedding_input:0': (None, 24)},
output_names=['dense_2/Sigmoid:0'])
model.save('xcodeModel.mlmodel')
不知道我在这里做错了什么。希望有答案!
【问题讨论】:
标签: python machine-learning keras coreml coremltools