0
0
TensorFlowml~10 mins

TensorFlow.js conversion - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to load a TensorFlow.js model from a URL.

TensorFlow
const model = await tf.loadLayersModel('[1]');
Drag options to blanks, or click blank then click option'
Amodel.h5
Bhttps://example.com/model.json
C./model.pb
Dmodel.pkl
Attempts:
3 left
💡 Hint
Common Mistakes
Using a Keras H5 file instead of a TensorFlow.js JSON model file.
Using a local file path without proper URL format.
2fill in blank
medium

Complete the code to convert a Keras model to TensorFlow.js format using the CLI.

TensorFlow
tensorflowjs_converter --input_format=keras [1] [2]
Drag options to blanks, or click blank then click option'
Amodel.h5
Bmodel.json
Ctfjs_model
Dsaved_model
Attempts:
3 left
💡 Hint
Common Mistakes
Using model.json as input instead of output.
Using saved_model as output folder for Keras input.
3fill in blank
hard

Fix the error in the code to correctly save a TensorFlow SavedModel for conversion.

TensorFlow
model.save('[1]');
Drag options to blanks, or click blank then click option'
A./saved_model
Bmodel.h5
Cmodel.json
Dtfjs_model
Attempts:
3 left
💡 Hint
Common Mistakes
Saving with a filename ending in .h5 instead of a folder path.
Using a JSON filename which is for TensorFlow.js, not TensorFlow SavedModel.
4fill in blank
hard

Fill both blanks to create a TensorFlow.js LayersModel from a Keras model and save it.

TensorFlow
const model = await tf.[1]('https://example.com/model.json');
await model.[2]('localstorage://my-model');
Drag options to blanks, or click blank then click option'
AloadLayersModel
Bsave
Cfit
Dcompile
Attempts:
3 left
💡 Hint
Common Mistakes
Using fit or compile instead of loading or saving methods.
Confusing method names for loading and saving.
5fill in blank
hard

Fill all three blanks to convert a TensorFlow SavedModel to TensorFlow.js format specifying input format and output directory.

TensorFlow
tensorflowjs_converter --input_format=[1] [2] [3]
Drag options to blanks, or click blank then click option'
Akeras
B./saved_model
C./tfjs_model
Dtf_saved_model
Attempts:
3 left
💡 Hint
Common Mistakes
Using keras as input format for SavedModel.
Not specifying output directory path.