OperatorNotAllowedInGraphError:在图形执行中不允许将tf.Tensor用作Python bool

问题描述 投票:1回答:1

嘿,我试图将我的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
1个回答
0
投票
© www.soinside.com 2019 - 2024. All rights reserved.