Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What is the purpose of monitoring accuracy during model training?
Monitoring accuracy helps you see how well your model is learning to make correct predictions on the training data.
Click to reveal answer
beginner
What does loss represent in model training?
Loss measures how far the model's predictions are from the true answers. Lower loss means better predictions.
Click to reveal answer
intermediate
How can you monitor accuracy and loss in TensorFlow during training?
You can pass metrics=['accuracy'] to model.compile() and TensorFlow will show accuracy and loss after each training epoch.
Click to reveal answer
intermediate
Why is it important to monitor both accuracy and loss?
Accuracy shows correct predictions, but loss shows how confident the model is. Monitoring both gives a fuller picture of training.
Click to reveal answer
advanced
What might it mean if accuracy improves but loss does not decrease?
It could mean the model is getting more predictions right but with less confidence or uneven errors. This needs careful checking.
Click to reveal answer
Which metric shows how many predictions are correct during training?
AAccuracy
BLoss
CLearning rate
DEpoch count
✗ Incorrect
Accuracy measures the percentage of correct predictions.
What does a decreasing loss value during training indicate?
AModel predictions are getting closer to true values
BModel is overfitting
CTraining data is increasing
DAccuracy is decreasing
✗ Incorrect
Lower loss means the model's predictions are closer to the actual answers.
In TensorFlow, where do you specify to track accuracy during training?
AIn model.evaluate() parameters
BIn model.fit() callbacks
CIn model.compile() under metrics
DIn the optimizer settings
✗ Incorrect
You add metrics=['accuracy'] in model.compile() to monitor accuracy.
If accuracy is high but loss is also high, what might this suggest?
AModel is confident but often wrong
BModel is correct but with low confidence
CModel is underfitting
DTraining stopped early
✗ Incorrect
High accuracy with high loss can mean correct predictions but low confidence or uneven errors.
Why monitor loss besides accuracy?
ALoss is only for testing
BLoss counts correct predictions
CLoss controls training speed
DLoss shows prediction confidence and error size
✗ Incorrect
Loss measures how far predictions are from true values, showing confidence and error size.
Explain how accuracy and loss monitoring help during model training.
Think about what each metric tells you about the model's learning.
You got /3 concepts.
Describe how to set up accuracy monitoring in TensorFlow model training.
Focus on the compile step where you tell TensorFlow what to track.
You got /2 concepts.
Practice
(1/5)
1. What is the main purpose of monitoring accuracy and loss during TensorFlow model training?
easy
A. To change the model architecture automatically
B. To track how well the model is learning and improving
C. To increase the size of the training dataset
D. To speed up the training process by skipping epochs
Solution
Step 1: Understand accuracy and loss roles
Accuracy shows how many predictions are correct, loss shows error size.
Step 2: Purpose of monitoring during training
Tracking these helps see if the model is learning or needs adjustment.
Final Answer:
To track how well the model is learning and improving -> Option B
Quick Check:
Accuracy and loss track learning progress = C [OK]
Hint: Accuracy and loss show model learning quality [OK]
Common Mistakes:
Thinking accuracy changes dataset size
Believing monitoring changes model structure
Assuming monitoring speeds training automatically
2. Which is the correct way to include accuracy monitoring when compiling a TensorFlow model?
easy
A. model.compile(optimizer='adam', loss='sparse_categorical_crossentropy', metrics=['accuracy'])
B. model.compile(optimizer='adam', loss='sparse_categorical_crossentropy')
C. model.compile(optimizer='adam', metrics=['accuracy'])
D. model.compile(loss='sparse_categorical_crossentropy', metrics='accuracy')
Solution
Step 1: Check required compile parameters
Optimizer and loss are required; metrics is optional for monitoring.
Step 2: Correct syntax for metrics
metrics must be a list like ['accuracy'], not a string alone.
Final Answer:
model.compile(optimizer='adam', loss='sparse_categorical_crossentropy', metrics=['accuracy']) -> Option A
Quick Check:
metrics=['accuracy'] in compile = B [OK]
Hint: Use metrics=['accuracy'] inside model.compile [OK]
Common Mistakes:
Omitting metrics parameter
Passing metrics as a string instead of list
Leaving out loss or optimizer
3. Given this code snippet, what will print(history.history['accuracy']) output?
model.compile(optimizer='adam', loss='sparse_categorical_crossentropy', metrics=['accuracy'])
history = model.fit(x_train, y_train, epochs=2)
print(history.history['accuracy'])
medium
A. A list of loss values for each epoch
B. A single float value of final accuracy, e.g. 0.90
C. An error because 'accuracy' is not in history
D. A list of accuracy values for each epoch, e.g. [0.85, 0.90]
Solution
Step 1: Understand history.history content
It stores lists of metric values per epoch, including accuracy if monitored.
Step 2: What history.history['accuracy'] returns
It returns a list of accuracy values, one per epoch, not a single value or error.
Final Answer:
A list of accuracy values for each epoch, e.g. [0.85, 0.90] -> Option D
Quick Check:
history.history['accuracy'] = list per epoch [OK]
Hint: history.history['accuracy'] holds accuracy per epoch list [OK]
Common Mistakes:
Expecting a single float instead of list
Confusing accuracy with loss values
Assuming key 'accuracy' is missing
4. You run this code but get a KeyError when accessing history.history['accuracy']. What is the likely cause?
model.compile(optimizer='adam', loss='sparse_categorical_crossentropy')
history = model.fit(x_train, y_train, epochs=3)
print(history.history['accuracy'])
medium
A. Accuracy was not included in metrics during model.compile
B. The model.fit call is missing the epochs parameter
C. The loss function is incorrect for accuracy monitoring
D. history.history only stores loss, not accuracy
Solution
Step 1: Check model.compile parameters
Accuracy monitoring requires metrics=['accuracy'] in compile, missing here.
Step 2: Effect on history.history keys
Without metrics=['accuracy'], history.history has no 'accuracy' key, causing KeyError.
Final Answer:
Accuracy was not included in metrics during model.compile -> Option A
Quick Check:
Missing metrics=['accuracy'] causes KeyError [OK]
Hint: Always add metrics=['accuracy'] to compile to track accuracy [OK]
Common Mistakes:
Forgetting to add metrics=['accuracy']
Assuming loss function controls accuracy keys
Thinking epochs parameter affects history keys
5. You want to monitor both accuracy and loss during training and plot their progress after training. Which code snippet correctly compiles the model and accesses the data for plotting?
hard
A. model.compile(optimizer='adam', loss='sparse_categorical_crossentropy', metrics='accuracy')
history = model.fit(x_train, y_train, epochs=5)
plt.plot(history['accuracy'])
plt.plot(history['loss'])
B. model.compile(optimizer='adam', loss='sparse_categorical_crossentropy')
history = model.fit(x_train, y_train, epochs=5)
plt.plot(history.history['accuracy'])
plt.plot(history.history['loss'])
C. model.compile(optimizer='adam', loss='sparse_categorical_crossentropy', metrics=['accuracy'])
history = model.fit(x_train, y_train, epochs=5)
plt.plot(history.history['accuracy'])
plt.plot(history.history['loss'])
D. model.compile(optimizer='adam', loss='sparse_categorical_crossentropy', metrics=['accuracy'])
history = model.fit(x_train, y_train, epochs=5)
plt.plot(history['accuracy'])
plt.plot(history['loss'])
Solution
Step 1: Check model.compile metrics syntax
metrics must be a list like ['accuracy']. B omits it, C uses string 'accuracy'.
Step 2: Check history access for plotting
history.history['accuracy'] and history.history['loss'] are correct; history['accuracy'] fails as history object lacks these attributes.
Final Answer:
model.compile(optimizer='adam', loss='sparse_categorical_crossentropy', metrics=['accuracy'])
history = model.fit(x_train, y_train, epochs=5)
plt.plot(history.history['accuracy'])
plt.plot(history.history['loss']) -> Option C
Quick Check:
metrics list + history.history keys = A [OK]
Hint: Use metrics=['accuracy'] and history.history for plotting [OK]