Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to save the TensorFlow model with a version number.
TensorFlow
model.save('model_v[1]')
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a string like 'version' instead of a number.
Using 'latest' which is not a version number.
✗ Incorrect
The version number is typically a simple integer like '1' to indicate the model version.
2fill in blank
mediumComplete the code to load a specific version of the saved TensorFlow model.
TensorFlow
loaded_model = tf.keras.models.load_model('model_v[1]')
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'latest' which is not a folder name.
Using 'version' which is not a valid folder.
✗ Incorrect
To load a specific version, use the version number like '1' that matches the saved folder.
3fill in blank
hardFix the error in the code to save the model with versioning correctly.
TensorFlow
model.save('model_v[1]')
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'v1' which duplicates the 'v' in the folder name.
Using '1.0' which can cause confusion in folder naming.
✗ Incorrect
The folder name should be simple and consistent, like 'model_v1'. Using '1' after 'v' is correct.
4fill in blank
hardFill both blanks to create a dictionary that maps model versions to their file paths.
TensorFlow
model_paths = {'v1': 'model_v[1]', 'v2': 'model_v[2]'} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'latest' as a folder name which is not versioned.
Mixing up the version numbers in the dictionary.
✗ Incorrect
The dictionary keys 'v1' and 'v2' map to folder names 'model_v1' and 'model_v2' respectively.
5fill in blank
hardFill all three blanks to load a model, make a prediction, and print the result.
TensorFlow
model = tf.keras.models.load_model('model_v[1]') prediction = model.predict([2]) print('Prediction:', [3])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'data' instead of 'input_data' for prediction input.
Printing 'data' instead of the prediction result.
✗ Incorrect
Load version 1 of the model, predict using 'input_data', and print the 'prediction' variable.