Can be either of the two formats
ModelAndWeightsConfig
JSON describing
the model in the canonical TensorFlow.js format. For file://
(tfjs-node-only), http:// and https:// schemas, the path can be
either absolute or relative. The content of the JSON file is assumed to
be a JSON object with the following fields and values:keras.Model.to_json()
keras.models.save_model()
.save_model()
for more details.
It is also assumed that model weights can be accessed from relative
paths described by the paths
fields in weights manifest.tf.io.IOHandler
object that loads model artifacts with its load
method.Optional
options: LoadOptionsOptional configuration arguments for the model loading, including:
strict
: Require that the provided weights exactly match those required
by the layers. Default true. Passing false means that both extra
weights and missing weights will be silently ignored.onProgress
: A progress callback of the form:
(fraction: number) => void
. This callback can be used to monitor the
model-loading process.A Promise
of tf.LayersModel
, with the topology and weights
loaded.
Generated using TypeDoc
Load a model composed of Layer objects, including its topology and optionally weights. See the Tutorial named "How to import a Keras Model" for usage examples.
This method is applicable to:
tf.layers.*
,tf.sequential
, andtf.model
APIs of TensorFlow.js and later saved with thetf.LayersModel.save
method.This mode is not applicable to TensorFlow
SavedModel
s or their converted forms. For those models, usetf.loadGraphModel
.Example 1. Load a model from an HTTP server.
Example 2: Save
model
's topology and weights to browser local storage; then load it back.Example 3. Saving
model
's topology and weights to browser IndexedDB; then load it back.Example 4. Load a model from user-selected files from HTML file input elements.