Complete the code to load a TensorFlow.js model from a URL.
const model = await tf.loadLayersModel('[1]');
The tf.loadLayersModel function loads a TensorFlow.js model from a URL or local path to a JSON file. The URL must point to a model.json file.
Complete the code to convert a Keras model to TensorFlow.js format using the CLI.
tensorflowjs_converter --input_format=keras [1] [2]
model.json as input instead of output.saved_model as output folder for Keras input.The tensorflowjs_converter command converts a Keras H5 model file (model.h5) to a TensorFlow.js format saved in a directory (tfjs_model).
Fix the error in the code to correctly save a TensorFlow SavedModel for conversion.
model.save('[1]');
To save a TensorFlow SavedModel format, you must provide a directory path (e.g., './saved_model'). Saving as .h5 saves a Keras H5 file, not a SavedModel.
Fill both blanks to create a TensorFlow.js LayersModel from a Keras model and save it.
const model = await tf.[1]('https://example.com/model.json'); await model.[2]('localstorage://my-model');
fit or compile instead of loading or saving methods.Use tf.loadLayersModel() to load a Keras converted model, then model.save() to save it to local storage in TensorFlow.js.
Fill all three blanks to convert a TensorFlow SavedModel to TensorFlow.js format specifying input format and output directory.
tensorflowjs_converter --input_format=[1] [2] [3]
keras as input format for SavedModel.To convert a TensorFlow SavedModel to TensorFlow.js format, specify --input_format=tf_saved_model, the SavedModel directory ./saved_model, and the output directory ./tfjs_model.