3.3.10 · D1Deep Learning Frameworks

Foundations — TensorBoard - Weights & Biases logging

2,034 words9 min readBack to topic

Before we can read a single line of the parent note, we need to make sure no word on this page is a mystery. Below, every symbol and term the parent uses is unpacked from zero: plain meaning → the picture it draws → why the topic needs it.


Start with the most basic object: a training loop

Everything logged comes out of a loop that repeats. If you have never seen one, here is the whole idea in a picture.

Look at the figure. The circle is one turn of the loop. Every turn spits out at least one number — the loss. That stream of numbers, turn after turn, is exactly what we want to record. Without the loop there is nothing to log; the loop is the source of all data.


The x-axis of everything: step and epoch

Every logged number needs an answer to "when did this happen?". Two words answer that.

In the figure, the long horizontal line is step — it never resets. Epochs are the coloured brackets grouping equal chunks of steps. The parent note computes:

global_step = epoch * len(train_loader) + batch_idx

Let's read that in plain words, because it is the single most important arithmetic on the parent page.

WHY multiply? Because alone restarts at every epoch. If we plotted against , epoch 2's points would land on top of epoch 1's points — the graph would be a scribble. Multiplying pushes each epoch's block of steps to a fresh, higher region of the x-axis so nothing overlaps. WHAT it looks like: a straight, always-increasing timeline (the flat line in the figure), never a loop-back.


The y-axis values: the four things we plot

The parent note logs four kinds of thing. Each is a different shape of picture. Here is what each word means before you ever meet its code.

1. Scalar — a single number

That is the plot you already imagined for loss. add_scalar(...) / wandb.log({...}) write these. The picture: a line chart, x = step, y = the number.

2. Histogram — the shape of a bag of numbers

A model does not hold one weight; a single layer holds thousands. To watch them all at once we need a picture of a whole collection of numbers.

Look at the figure: the same 5,000 weight values, drawn as a histogram. WHY the topic needs this: a single scalar can't tell you if a layer's weights are all collapsing to zero (dead neurons) or blowing up. The shape of the bag tells you. This is the direct link to vanishing / exploding gradients — a histogram of gradients that shrinks toward a spike at zero is what "vanishing" looks like.

3. Image — a grid of pixels

4. Graph — the model's wiring diagram


Where the numbers get written: the writer and the file

We have numbers and we have timestamps. Now: how do they leave the running program?

The figure shows the flow: loop → writer → event file → (later) the viewer draws the plot. Two crucial properties, both visible as one-way arrows:

  • Append-only: new records are only ever added to the end, never rewritten. WHY? If training crashes at step 5000, everything up to 5000 is already safely on disk — nothing is lost. That is the "crash-safe" claim in the parent note.
  • Decoupled: the viewer reads the file independently of the training program. WHY? You can open the plots while training still runs, or days after it finished, from a different terminal.

The vocabulary of "what we're tuning": hyperparameters, metrics, artifacts

The parent's definition of experiment tracking uses three category words. Pin them down.


Two words the parent leans on: reproducibility and provenance

This is the bridge to model versioning: an artifact (a checkpoint) plus its provenance (the exact run that made it) is a versioned model you can trust and retrieve.


How the pieces feed the topic

Training loop repeats

Produces numbers each turn

step and epoch = when

scalar histogram image graph = what

global step formula

SummaryWriter writes records

Event file on disk append only

Viewer draws the plots

Hyperparameters metrics artifacts

Provenance git and versions

Experiment tracking

Read it top to bottom: the loop makes numbers, we tag them with when and what, a writer files them, and a viewer turns the file back into pictures. Add the categories and provenance, and you have full experiment tracking — the parent topic.


Equipment checklist

Cover the right side and answer. If any answer surprises you, re-read that section before the parent note.

What is one turn of a training loop that processes one batch called?
A step (a.k.a. iteration / global_step).
What is one full pass over the entire dataset called?
An epoch.
Why do we compute global_step = epoch * B + batch_idx instead of just plotting batch_idx?
Because batch_idx resets to 0 each epoch; multiplying pushes each epoch to a fresh, non-overlapping region of the x-axis.
A "scalar" is what shape of data?
A single number per timestep — plotted as a line.
A "histogram" answers what question about a bag of numbers?
How many values fall into each range (bin) — it shows the distribution's shape.
Which log type helps you diagnose vanishing/exploding gradients?
Histograms of weights or gradients.
What does a SummaryWriter do?
Writes logged (name, value, step) records to disk.
Why is an event file "append-only", and what benefit does that give?
New records are only added to the end; if training crashes, everything logged so far is already safely saved (crash-safe).
Difference between a hyperparameter and a metric?
Hyperparameter = a knob you set before training (input, e.g. lr); metric = a number training produces (output, e.g. loss).
What is an artifact?
A file the run produces that you keep — e.g. a model checkpoint or a saved image.
What is "provenance" and why log it?
The origin trail (code version, library versions, hardware); logging it gives reproducibility.
For a dataset of 60,000 samples with batch size 64, roughly how many steps per epoch?
60000 / 64 ≈ 938 steps.