Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to save a trained model using versioning.
ML Python
model.save('model_v[1].h5')
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using strings like 'latest' or 'best' without a number can cause confusion in versioning.
✗ Incorrect
The version number '1' is used to save the first version of the model file.
2fill in blank
mediumComplete the code to load a specific model version.
ML Python
loaded_model = load_model('model_v[1].h5')
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using non-numeric strings like 'best' or 'latest' without a clear version number.
✗ Incorrect
Loading model version '2' specifies which saved model to use.
3fill in blank
hardFix the error in the code to properly save the model with versioning.
ML Python
model.save('model_[1].h5')
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '1v' or 'ver1' which are less clear or unconventional.
✗ Incorrect
The convention 'v1' clearly indicates version 1 and is commonly used.
4fill in blank
hardFill both blanks to create a dictionary that maps model versions to their file paths.
ML Python
model_versions = {'v1': '[1]', 'v2': '[2]'} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing version keys with unrelated file names like 'latest' or 'best'.
✗ Incorrect
The dictionary keys 'v1' and 'v2' map to their respective model files.
5fill in blank
hardFill all three blanks to load a model version from the dictionary and make a prediction.
ML Python
model_path = model_versions['[1]'] loaded_model = load_model(model_path) prediction = loaded_model.predict([2]) print('Prediction for version [3]:', prediction)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using mismatched version keys or wrong data variable names.
✗ Incorrect
We load version 'v1', predict on 'test_data', and print the prediction for 'v1'.