Continuously Train Coreml Model After Shipping

Continuously train CoreML model after shipping

The .mlmodel file is compiled by Xcode into a .mlmodelc structure (which is actually a folder inside your app bundle).

Your app might be able to download a new .mlmodel from a server but I don't think you can run the Core ML compiler from inside your app.

Maybe it is possible for your app to download the compiled .mlmodelc data from a server, copy it into the app's Documents directory, and instantiate the model from that. Try it out. ;-)

(This assumes the App Store does not do any additional processing on the .mlmodelc data before it packages up your app and ships it to the user.)

Continuously train CoreML model after shipping

The .mlmodel file is compiled by Xcode into a .mlmodelc structure (which is actually a folder inside your app bundle).

Your app might be able to download a new .mlmodel from a server but I don't think you can run the Core ML compiler from inside your app.

Maybe it is possible for your app to download the compiled .mlmodelc data from a server, copy it into the app's Documents directory, and instantiate the model from that. Try it out. ;-)

(This assumes the App Store does not do any additional processing on the .mlmodelc data before it packages up your app and ships it to the user.)

Is it possible to train a CoreML model on device as the app runs?

It's now possible with Core ML 3.
https://developer.apple.com/videos/play/wwdc2019/704/
Skip to 9:00 to see it in action. If you just want the code, skip to 13:50.

CoreML - On device model training

Currently your options are:

  • use Metal Performance Shaders to train on the device
  • write your own training code

Neither is compatible with Core ML (although if you really wanted to, you could write your own mlmodel file and then compile it on the device).

Prepping to update a Core ML Model

If your Model is Named TestModel a TestModelTrainingInput class should be available.

let singleTrainingData = try TestModelTrainingInput(input: .init[1,2,3], output_true: .init([4,5,6]))
let trainingData = MLArrayBatchProvider(array: [singleTrainingData])


Related Topics



Leave a reply



Submit