【发布时间】:2021-03-28 22:46:33
【问题描述】:
我的 keras 模型:
model = Sequential()
model.add(LSTM(128, return_sequences=True, input_shape=(18, 63)))
model.add(LSTM(64))
model.add(Dense(3, activation='softmax'))
model.compile(loss='sparse_categorical_crossentropy',
optimizer='adam', metrics=['accuracy'])
model.fit(X, Y, batch_size=30, verbose=2, epochs=90,validation_split=0.2)
我尝试将模型转换为 coreml:
coreml_model = coremltools.converters.keras.convert(
model,
input_names=['input'],
output_names=["output"])
我收到此错误:
TypeError: 'InputLayer' object is not iterable
更新:
有
coreml_model = coremltools.convert(...)
我得到这个错误(这里是一个不完整的错误代码)
InvalidArgumentError: Attempting to add a duplicate function with name: while_cond_45890 where the previous and current definitions differ. Previous definiton: signature {
name: "while_cond_45890"
input_arg {
name: "while_while_loop_counter"
type: DT_INT32
}
input_arg {
name: "while_while_maximum_iterations"
type: DT_INT32
}
....
【问题讨论】:
-
这个thread 可能会有所帮助。
-
不幸的是这没有帮助
-
我遇到了同样的错误,如果你设法修复它,请告诉我
-
我决定使用 tflite 模型。它没有任何其他方式工作
-
那么你是把你的 Keras 模型转换成 tflite 还是重写了整个模型?
标签: keras converters coreml