0
0
TensorFlowml~20 mins

Model versioning in TensorFlow - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Model Versioning Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
Why use model versioning in machine learning?

Imagine you train a model and later improve it. Why is it important to keep versions of your models?

ATo avoid using any validation data
BTo make the model training faster
CTo reduce the size of the model files
DTo track changes and compare performance between different models
Attempts:
2 left
💡 Hint

Think about how you keep different drafts of a document to see which one is better.

Predict Output
intermediate
2:00remaining
What is the output of this TensorFlow model save code?

Consider this code saving a model with versioning:

import tensorflow as tf
model = tf.keras.Sequential([tf.keras.layers.Dense(1, input_shape=(3,))])
model.save('models/v1')

What will be created in the filesystem?

TensorFlow
import tensorflow as tf
model = tf.keras.Sequential([tf.keras.layers.Dense(1, input_shape=(3,))])
model.save('models/v1')
AAn error because the path is a folder, not a file
BA single file named 'models/v1.h5' saved in the current directory
CA folder named 'models/v1' containing the saved model files
DNothing saved because the model is not compiled
Attempts:
2 left
💡 Hint

TensorFlow saves models in folders when given a directory path.

Hyperparameter
advanced
1:30remaining
Choosing the right version number for a new model

You have saved model versions 'v1', 'v2', and 'v3'. You retrain the model with more data and want to save the new model. Which version number should you use?

Av2, to overwrite the previous model with the same data
Bv4, because it is the next sequential version
Cv1, to keep the version numbers low
Dv10, to skip numbers and confuse users
Attempts:
2 left
💡 Hint

Think about how software versions increase logically.

Metrics
advanced
1:30remaining
Comparing model versions using accuracy

You have two model versions saved: v1 with accuracy 0.85 and v2 with accuracy 0.83. Which model should you deploy?

Av1, because it has higher accuracy
Bv2, because lower accuracy means faster predictions
CNeither, because accuracy is not important
Dv2, because it is the latest version regardless of accuracy
Attempts:
2 left
💡 Hint

Higher accuracy usually means better predictions.

🔧 Debug
expert
2:00remaining
Why does loading a saved model version fail?

You saved a TensorFlow model with model.save('models/v1'). Later, you try to load it with tf.keras.models.load_model('models/v2') and get an error. Why?

ABecause 'models/v2' folder does not exist or has no saved model
BBecause the model was saved with the wrong TensorFlow version
CBecause the model was not compiled before saving
DBecause the load_model function requires a file, not a folder
Attempts:
2 left
💡 Hint

Check if the folder you are loading from actually exists.