Overview
After training a model, (a time intensive operation) you will want to save the results somewhere so that you can just load the model from the saved format and go.
Saving/Loading Models
The tensorflow library provides a method for saving the model to disk.
await model.save('downloads://my-model');
Once the model is saved to disk, it can be loaded. However, the typical way to load the save model is from a file hosted on a webserver. (you may need to copy the model file to a webserver, or to your media on the davinci platform)
const model1 = await tf.loadLayersModel('http://model-server.domain/download/model.json');
const model2 = await tf.loadLayersModel('file://path/to/my-model/model.json');
Try it!
Serialization
The tensor flow utility provides an alternate method for serializing a model to json text and to deserialize the model from the json.
let ut = await import('/lib/tensor-flow/util/v1.0.0/util.mjs');
let text = await ut.serialize(model);
let model2 = await ut.deserialize(text);
Try it!