* Load the model from IndexedDB. * * @returns {SaveablePolicyNetwork} The instance of loaded * `SaveablePolicyNetwork`. * @throws {Error} If no model can be found in IndexedDB.
()
| 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. |