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

Method loadModel

cart-pole/index.js:278–288  ·  view source on GitHub ↗

* Load the model from IndexedDB. * * @returns {SaveablePolicyNetwork} The instance of loaded * `SaveablePolicyNetwork`. * @throws {Error} If no model can be found in IndexedDB.

()

Source from the content-addressed store, hash-verified

276 * @throws {Error} If no model can be found in IndexedDB.
277 */
278 static async loadModel() {
279 const modelsInfo = await tf.io.listModels();
280 if (MODEL_SAVE_PATH_ in modelsInfo) {
281 console.log(`Loading existing model...`);
282 const model = await tf.loadLayersModel(MODEL_SAVE_PATH_);
283 console.log(`Loaded model from ${MODEL_SAVE_PATH_}`);
284 return new SaveablePolicyNetwork(model);
285 } else {
286 throw new Error(`Cannot find model at ${MODEL_SAVE_PATH_}.`);
287 }
288 }
289
290 /**
291 * Check the status of locally saved model.

Callers 1

setUpUIFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected