0
0
TensorFlowml~10 mins

Loading and inference in TensorFlow - 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 saved TensorFlow model.

TensorFlow
import tensorflow as tf
model = tf.keras.models.[1]('my_model')
Drag options to blanks, or click blank then click option'
Acompile_model
Bsave_model
Cload_model
Dfit_model
Attempts:
3 left
💡 Hint
Common Mistakes
Using save_model instead of load_model
Trying to compile or fit the model during loading
2fill in blank
medium

Complete the code to make predictions using the loaded model.

TensorFlow
predictions = model.[1](input_data)
Drag options to blanks, or click blank then click option'
Atrain
Bfit
Cevaluate
Dpredict
Attempts:
3 left
💡 Hint
Common Mistakes
Using fit or train instead of predict
Using evaluate which returns loss and metrics
3fill in blank
hard

Fix the error in the code to load a model from the file 'model.h5'.

TensorFlow
model = tf.keras.models.load_model([1])
Drag options to blanks, or click blank then click option'
Amodel.h5
B"model.h5"
Cmodel
D'model'
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the filename without quotes
Passing a variable name instead of a string
4fill in blank
hard

Fill both blanks to create a dictionary of predictions for each input sample.

TensorFlow
results = {i: model.[1](sample) for i, sample in enumerate([2])}
Drag options to blanks, or click blank then click option'
Apredict
Binput_data
Cfit
Devaluate
Attempts:
3 left
💡 Hint
Common Mistakes
Using fit or evaluate instead of predict
Using wrong variable name for input data
5fill in blank
hard

Fill all three blanks to load a model, make predictions, and print the results.

TensorFlow
model = tf.keras.models.[1]('saved_model')
preds = model.[2](test_data)
print([3])
Drag options to blanks, or click blank then click option'
Aload_model
Bpredict
Cpreds
Dfit
Attempts:
3 left
💡 Hint
Common Mistakes
Using fit instead of predict
Printing the wrong variable
Not using quotes for the model path