Skip to main content

Stage 5: Train and Read the Learning Signals

Course progressStage 5 of 10
~90 min
Your workspace

Keep your Colab notebook tab open all session. Open in a new tab — don’t use the buttons in this page to leave the course.

Build

a baseline training run with saved history and learning charts

Learn

how epochs, loss, accuracy, and validation signals show whether learning is healthy

Ship

baseline charts plus one written read of the training behavior

Teacher demo

Start training on the projector and read one epoch row aloud. Ask which numbers should go up and which should go down.

The big idea

Training is not just waiting for a cell to finish. It is an experiment with signals to read.

During each epoch, the model guesses, measures loss, adjusts parameters, and tries again. Accuracy should climb. Loss should fall. Validation tells us whether it is learning ideas that work on unseen data.

model.fit is the training command. It does not just calculate a score; it repeatedly changes the model's learned parameters to reduce mistakes. The object it returns, baseline_history, is the training log you will read after the run.

How the Python ML workflow connects
  1. 1
    Photos / CIFAR-10labeled image examplesStage 1
  2. 2
    Notebook variablesx_train, y_train, class_namesSetup-2
  3. 3
    Prepared datanormalized pixels and fair pilesStage 3
  4. 4
    Keras modelCNN layers and summaryStage 4
  5. 5
    Training historyepochs, loss, accuracyStage 5
  6. 6
    Test evidencesealed score and mistakesStages 6-7
  7. 7
    Improved modelaugmentation comparisonStage 8
  8. 8
    Inferenceuploaded image to top-3 guessesStage 9
  9. 9
    Demo evidencetable, confidence, limitationStage 10

Stage 5 connects the prepared data and Keras model to training history. The epoch log and charts show whether learning is happening.

New words
epoch
one full pass through the training data
loss
how wrong the model is, as a number to shrink
accuracy
the fraction of examples predicted correctly
history
the saved record of training metrics
baseline
the first result used for comparison later
Before you start

You need the compiled model from Stage 4 and prepared data from Stage 3.

Build it

Step 1 — Predict the baseline result

In a text cell:

Baseline prediction:
- I think final training accuracy will be about _____%.
- I think final validation accuracy will be about _____%.
- I expect validation to be lower / higher / about the same because __________.

Step 2 — Train the baseline model

When the cell runs, watch the epoch rows before scrolling away. Each row records one practice round.

baseline_history = model.fit(
x_train,
y_train,
epochs=10,
validation_data=(x_val, y_val)
)

Watch the epoch rows. Do not ignore them. Each row is evidence.

Step 3 — Print the final training signals

final_train_acc = baseline_history.history['accuracy'][-1]
final_val_acc = baseline_history.history['val_accuracy'][-1]
final_train_loss = baseline_history.history['loss'][-1]
final_val_loss = baseline_history.history['val_loss'][-1]

print(f"Final train accuracy: {final_train_acc:.3f}")
print(f"Final validation accuracy: {final_val_acc:.3f}")
print(f"Final train loss: {final_train_loss:.3f}")
print(f"Final validation loss: {final_val_loss:.3f}")

Step 4 — Chart accuracy and loss

plt.plot(baseline_history.history['accuracy'], label='train accuracy')
plt.plot(baseline_history.history['val_accuracy'], label='validation accuracy')
plt.title('Baseline accuracy')
plt.xlabel('Epoch')
plt.ylabel('Accuracy')
plt.legend()
plt.show()

plt.plot(baseline_history.history['loss'], label='train loss')
plt.plot(baseline_history.history['val_loss'], label='validation loss')
plt.title('Baseline loss')
plt.xlabel('Epoch')
plt.ylabel('Loss')
plt.legend()
plt.show()

Step 5 — Write your learning read

Training read:
- Accuracy went up / down / stayed flat.
- Loss went up / down / stayed flat.
- Validation stayed close to training / fell behind training.
- My evidence is __________.

Understand it

Training accuracy measures pictures the model practiced on. Validation accuracy measures pictures held aside from training. If training climbs while validation flattens or falls, the model may be learning details that do not generalize.

Loss is often the better early warning. Accuracy can look stable while loss shows guesses becoming more or less confident.

Try this

Learning beat

Try this

Three short experiments. Predict before you run, then test your guess.

Predict first

Before viewing the chart, predict whether validation accuracy stayed close to training accuracy. Then compare.

Compare

Find one epoch where validation accuracy dropped from the previous epoch. Does one bad epoch mean training failed?

Connect

Why will Stage 6 need a sealed test score if we already have validation accuracy?

Test your stage

  • Training completed 10 epochs.
  • You printed final training and validation accuracy.
  • You made accuracy and loss charts.
  • Workflow check. Point to this stage on the workflow map and explain how training history becomes evidence.
  • Evidence check. Your training read compares the first and last epoch, not only the final score.
  • Design check. Your text cell explains whether the model appears to be learning healthily.

If it breaks

  • Training is slow. Check GPU in Runtime settings.
  • Accuracy stays near 0.10. Labels or final output shape are probably wrong. Re-run Stages 3 and 4.
  • baseline_history is undefined. Run the training cell first.
Coach notes

Make students write the training read. That turns the stage from a tutorial wait into evidence-based interpretation.