0
0
TensorFlowml~10 mins

Why model persistence enables deployment in TensorFlow - Test Your Understanding

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

Complete the code to save a trained TensorFlow model.

TensorFlow
model.[1]('my_model')
Drag options to blanks, or click blank then click option'
Acompile
Bload
Cfit
Dsave
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'load' instead of 'save' will cause an error because 'load' is not a method of the model object.
Using 'fit' saves training the model, not saving it.
Using 'compile' prepares the model for training, not saving.
2fill in blank
medium

Complete the code to load a saved TensorFlow model.

TensorFlow
loaded_model = tf.keras.models.[1]('my_model')
Drag options to blanks, or click blank then click option'
Asave
Bfit
Cload_model
Dcompile
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'save' instead of 'load_model' will cause an error because 'save' is a method of model, not a function to load.
Using 'fit' is for training, not loading.
Using 'compile' is for preparing the model, not loading.
3fill in blank
hard

Fix the error in the code to save the model in HDF5 format.

TensorFlow
model.[1]('my_model.h5')
Drag options to blanks, or click blank then click option'
Afit
Bsave
Cload
Dcompile
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'load' instead of 'save' causes an error because 'load' is for loading models.
Using 'fit' or 'compile' does not save the model.
4fill in blank
hard

Fill both blanks to create a dictionary of predictions for inputs greater than 0.5.

TensorFlow
predictions = {x: model.predict([[x]])[0][0] for x in inputs if x [1] 0.5 and model.predict([[x]])[0][0] [2] 0.7}
Drag options to blanks, or click blank then click option'
A>
B<
C==
D!=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' in the first blank would select inputs less than 0.5, which is incorrect.
Using '>' in the second blank would select predictions greater than 0.7, which is not intended.
5fill in blank
hard

Fill all three blanks to create a dictionary of predictions for inputs where prediction is above 0.6 and input is less than 1.0.

TensorFlow
results = { [1] : [2] for [3] in data if data[[3]] > 0.6 and [3] < 1.0 }
Drag options to blanks, or click blank then click option'
Ax
Bdata[x]
Dy
Attempts:
3 left
💡 Hint
Common Mistakes
Using different variable names for key and loop variable causes errors.
Using 'y' as loop variable without defining it causes errors.