0
0
TensorFlowml~10 mins

Training history and visualization 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 train the model and save the training history.

TensorFlow
history = model.fit(X_train, y_train, epochs=[1], validation_split=0.2)
Drag options to blanks, or click blank then click option'
A100
B5
C50
D10
Attempts:
3 left
💡 Hint
Common Mistakes
Using too many epochs can cause long training times.
Forgetting to set epochs causes an error.
2fill in blank
medium

Complete the code to plot training accuracy from the history object.

TensorFlow
plt.plot(history.history['[1]'])
Drag options to blanks, or click blank then click option'
Aaccuracy
Bval_accuracy
Cval_loss
Dloss
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'loss' instead of 'accuracy' to plot accuracy.
Using validation keys when plotting training metrics.
3fill in blank
hard

Fix the error in the code to plot validation loss correctly.

TensorFlow
plt.plot(history.history['[1]'])
Drag options to blanks, or click blank then click option'
Aval_loss
Bval_accuracy
Closs_val
Dval_acc
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'val_acc' or 'loss_val' which are invalid keys.
Mixing validation accuracy key with loss key.
4fill in blank
hard

Fill both blanks to plot training and validation accuracy.

TensorFlow
plt.plot(history.history['[1]'], label='train')
plt.plot(history.history['[2]'], label='validation')
plt.legend()
Drag options to blanks, or click blank then click option'
Aaccuracy
Bval_accuracy
Closs
Dval_loss
Attempts:
3 left
💡 Hint
Common Mistakes
Plotting loss keys instead of accuracy keys.
Mixing training loss with validation accuracy.
5fill in blank
hard

Fill all three blanks to create a dictionary of training loss, validation loss, and epochs.

TensorFlow
results = {
  '[1]': history.history['loss'],
  '[2]': history.history['val_loss'],
  '[3]': list(range(1, len(history.history['loss']) + 1))
}
Drag options to blanks, or click blank then click option'
Atrain_loss
Bvalidation_loss
Cepochs
Dloss
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect or inconsistent dictionary keys.
Not creating the epochs list correctly.