0
0
TensorFlowml~20 mins

TensorFlow.js conversion - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
TensorFlow.js Conversion Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Output of TensorFlow.js model prediction after conversion
Given a TensorFlow model converted to TensorFlow.js format and loaded in the browser, what will be the output shape of the prediction for an input tensor of shape [1, 28, 28, 1]?
TensorFlow
const input = tf.zeros([1, 28, 28, 1]);
const model = await tf.loadLayersModel('model.json');
const prediction = model.predict(input);
prediction.shape;
A[10]
B[28, 28, 1]
C[1, 784]
D[1, 10]
Attempts:
2 left
💡 Hint
Think about the output layer size of a typical classification model for 10 classes.
Model Choice
intermediate
2:00remaining
Choosing the correct TensorFlow.js model format for conversion
Which TensorFlow saved model format is compatible for direct conversion to TensorFlow.js using the tensorflowjs_converter tool?
ATensorFlow Lite flatbuffer file
BTensorFlow SavedModel directory with saved_model.pb and variables/
CTensorFlow checkpoint files only
DKeras HDF5 (.h5) file only
Attempts:
2 left
💡 Hint
The converter expects a full SavedModel directory structure.
Hyperparameter
advanced
2:00remaining
Effect of quantization during TensorFlow.js model conversion
What is the main effect of applying 8-bit quantization during TensorFlow.js model conversion?
AConverts the model to use float64 precision for better stability
BRemoves dropout layers from the model
CReduces model size and speeds up inference with slight accuracy loss
DIncreases model size but improves accuracy
Attempts:
2 left
💡 Hint
Quantization trades precision for smaller size and faster speed.
🔧 Debug
advanced
2:00remaining
Identifying error when loading a TensorFlow.js model
You try to load a TensorFlow.js model with tf.loadLayersModel('model.json') but get a 404 error. What is the most likely cause?
AThe model.json file path is incorrect or the file is missing on the server
BThe model.json file is corrupted and cannot be parsed
CThe input tensor shape does not match the model input shape
DThe browser does not support WebGL
Attempts:
2 left
💡 Hint
A 404 error means the file was not found at the specified URL.
🧠 Conceptual
expert
3:00remaining
Understanding the difference between TensorFlow.js Layers and Graph models
Which statement correctly describes the difference between TensorFlow.js Layers API models and Graph models?
ALayers API models are high-level and easier to use; Graph models are low-level and support arbitrary TensorFlow graphs
BGraph models are deprecated and replaced by Layers API models
CLayers API models only support CPU execution; Graph models support GPU
DGraph models are only for training; Layers API models are only for inference
Attempts:
2 left
💡 Hint
Think about abstraction levels and flexibility.