Skip to content

Training

Philip Dow edited this page Feb 7, 2020 · 3 revisions

Additional information about training is forthcoming.

Check Training

After you've tested that training with your model has worked you can verify that the model has actually updated its weights by exporting it and comparing the update against the original version. We'll use the command line to do this.

Exporting a model in Swift is straightforward. On the simulator, run:

let exportUrl = URL(fileURLWithPath: NSTemporaryDirectory())
do { try model.export(to: exportUrl) } catch {
  print(error)
}
        
print("Model saved to \(exportUrl)")

Open that directory or list its contents in the terminal. You'll find two files at that location:

checkpoint.index
checkpoint.data-00000-of-00001

Hexdump the data file with the xxd command:

$ xxd checkpoint.data-00000-of-00001 > update.hexdump

And do the same for the variables data file from your original embedded model:

$ xxd variables.data-00000-of-00001 > original.hexdump

Finally diff the two hexdumps and pipe it the word count command requesting the number of lines:

$ diff update.hexdump original.hexdump | wc -l

You should see a large number, in the hundreds of thousands for a MobileNet model.

Congratulations! You just trained a model on device (or on the simulator), exported the update, and confirmed that the model did in fact train.

~

Last updated 2/6/19

Clone this wiki locally