尝试使用 coremltools 4.1 将模型转换为 coreml 不工作

Trying to convert model to coreml with coremltools 4.1 NOT WORKING

我正在使用 coremltools 4.1 将我的模型转换为 coreml,但出于某种原因,我收到此错误:TypeError: 'InputLayer' object is not iterable 并在线 coreml_model = coremltools.converters.keras.convert(model)。任何人都可以知道我在我的代码中做错了什么。谢谢您的帮助。这是我的片段。

import coremltools


coreml_model = coremltools.converters.keras.convert(model)

# setup the meta datas foor our coreml modal
coreml_model.author = 'Author'
coreml_model.license = 'MIT'
coreml_model.short_description = 'Predicts the character passed in as a number between 1-9.'
coreml_model.input_description['image'] = 'A 28x28 pixel grayscale image.'
coreml_model.output_description['output1'] = 'A Multiarray where the index with the greatest float value between 0 and 1 is the recognized number.'
coreml_model.save('NumberRecognition.mlmodel')
print('model converted')

不要使用 coremltools.converters.keras.convert,而是 coremltools.convert(...)。有关详细信息,请参阅文档:https://coremltools.readme.io/docs/introductory-quickstart