4

I'm trying to implement the new CoreML 3 feature of updatable Models into my App, but I can't figure it out.

Im creating a Neural Network with 2 layers in Keras and convert it to a core ML Model. Then I include the model into my iOS Project. However self.testmodel.model.modelDescription.isUpdatable is always false, and I can't make sense of the apple docs.

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")

Integrated in Swift I can now use the Model, but can't update it

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

Why isn't my model updatable and how can I change that?

Seb
  • 1,586
  • 1
  • 11
  • 15

1 Answers1

1

You can pass the respect_trainable=True argument to coremltools.converters.keras.convert().

Alternatively, you can change the mlmodel file after the conversion to make the model updatable. Official documentation in the form of examples is here: https://github.com/apple/coremltools/tree/master/examples/updatable_models

Matthijs Hollemans
  • 7,706
  • 2
  • 16
  • 23
  • Ahh, I see, you also need to use the beta version `3.0b5` of coremltools. That makes sense. Thank you very much – Seb Sep 05 '19 at 17:04
  • However trying to update the model throws the error: [espresso] Training kernels not enabled for engine: 100 And doesn’t update – Seb Sep 19 '19 at 11:20
  • @SebastianJ.Vogt I keep receiving the same message, however the model updating is working in my case. Are you using [modelName]TrainingInput class for providing training inputs? – Bghaak Sep 24 '19 at 08:15
  • I just haven't saved the model in the completion handler – Seb Sep 25 '19 at 11:19