4

我正在尝试在我的应用程序中实现可更新模型的新 CoreML 3 功能,但我无法弄清楚。

我在 Keras 中创建了一个具有 2 层的神经网络,并将其转换为核心 ML 模型。然后我将模型包含到我的 iOS 项目中。然而self.testmodel.model.modelDescription.isUpdatable总是错误的,我无法理解苹果文档。

model = Sequential([
    Dense(10, activation="sigmoid", input_shape=(2,)),
    Dense(2, activation="relu"),
])
core_mlmodel = coremltools.converters.keras.convert(model)
core_mlmodel.save("FirstNN.mlmodel")

集成到 Swift 我现在可以使用模型,但不能更新它

let testmodel = FirstNN()
try testmodel.prediction(input: input) // works
testmodel.model.modelDescription.isUpdatable  // is false

为什么我的模型不可更新,我该如何更改?

4

1 回答 1

1

您可以将respect_trainable=True参数传递给coremltools.converters.keras.convert().

或者,您可以在转换后更改 mlmodel 文件以使模型可更新。示例形式的官方文档在这里:https ://github.com/apple/coremltools/tree/master/examples/updatable_models

于 2019-09-05T16:09:37.717 回答