MCPcopy Create free account
hub / github.com/tensorflow/tfjs-examples / loadModel

Method loadModel

lstm-text-generation/index.js:165–176  ·  view source on GitHub ↗

* Create LSTM model if it is not saved locally; load it if it is. * * @param {number | number[]} lstmLayerSizes Sizes of the LSTM layers, as a * number or an non-empty array of numbers.

(lstmLayerSizes)

Source from the content-addressed store, hash-verified

163 * number or an non-empty array of numbers.
164 */
165 async loadModel(lstmLayerSizes) {
166 const modelsInfo = await tf.io.listModels();
167 if (this.modelSavePath_ in modelsInfo) {
168 console.log(`Loading existing model...`);
169 this.model = await tf.loadLayersModel(this.modelSavePath_);
170 console.log(`Loaded model from ${this.modelSavePath_}`);
171 } else {
172 throw new Error(
173 `Cannot find model at ${this.modelSavePath_}. ` +
174 `Creating model from scratch.`);
175 }
176 }
177
178 /**
179 * Save the model in IndexedDB.

Callers 1

setUpUIFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected