Chapter 4 in review,
then: what went wrong?

Session 25 · Mon Nov 30 · Book section 4.7 (game, §4–7)

🎲

Today’s question

Five training runs on five geoscience systems each hide one error. From the evidence alone, can your team name the error, fix it, and say which number shows that the fix worked?

1 local earthquakes at one seismic station
2 igneous rocks of a continental arc
3 a volcano during a seismic swarm
4 a GNSS station moving with its plate
5 igneous rocks along a differentiation trend

Review of Chapter 4 · game: 4.7 (game) What went wrong? · then 4.7 §4–7 · Ch 5 flipped reading assigned today (quiz closes Thu Dec 3)

The canonical networks, and what each is good for

Each layer assumes how its inputs are related. Choose the one whose assumption holds for your data.

A decision guide

Start from one data sample and ask what it is. The answer chooses the network and the baseline it must beat.

Each network against its baseline

Data (notebook) Network Baseline Verdict
PNW features (4.1) 89.2% forest 88.5% tie
P395 summaries (4.2) 0.70 mm linear 0.63 linear
waveforms (4.3) SNR 1.4 STA/LTA ≈ 9 network
warming maps (4.3) 0.008 known terms 0.009 tie
GNSS series (4.4) 1.87–1.95 mm persistence 2.10 network
shaking at stations (4.5) 0.137 IDW 0.182 network
CO₂ (4.9) MASE 0.327 SARIMA 0.256 SARIMA

The training checklist, for any network

Step Practice Rubric
Before split, scale, baseline, ranges A3–A7
Start seeded random weights D1
Loss fits Y and its errors; class weights if unbalanced D2
Optimizer Adam at 0.001; look at the curve D5
Stop lowest validation loss; checkpoint D4, D6
Report three seeds; test once; ties are ties D7, D8, E3

Read the two curves: today’s diagnostic tool

Training loss Validation loss Diagnosis First fix
high, flat high, flat learns nothing learning rate; check the inputs
jumps jumps learning rate too large divide it by 3 to 10
falls falls with it still learning more epochs
falls lowest, then rises overfitting checkpoint; smaller network; dropout
low far above, from the start validation unlike training the split, the ranges (A4, A7)

The game: what went wrong?

Five training runs, each with one hidden error.

Each case: 4 minutes, teams of 3 or 4 points
Name the cause 1
Propose a fix 1
Say which number would show that the fix worked 1

Then the reveal: the cause, the fix, and the number before and after.

Notebook 4.7 (game) What went wrong?: edit c<k>_fix() and run the evaluation cell until it prints PASS. The whole notebook runs in under a minute on a laptop CPU.

Case 1: a detector that scores 0.97 on its test set

Data 2000 records of 30 s, half earthquakes; 5 windows of 25 s each, shifted by 0.5 s
Split the 10 000 windows shuffled, then 60 / 20 / 20
Model spectrum in 20 bands → 64 → 64 → 2
Claim validation 0.962, test 0.971

Case 1: what went wrong

Windows of one record fell on both sides of the split. Split the records first: validation 0.779, new events 0.792.

Case 2: the network calls every rock granite

Data 4,000 rocks: oxides in wt%, K in ppm, density in kg/m³, susceptibility in 10⁻⁶ SI
Split random, stratified: 2,400 / 800 / 800
Model 9 → 32 → 32 → 3, SGD, learning rate 0.1, 40 epochs
Claim “validation 0.556: the measurements cannot separate the rocks”

Case 2: what went wrong

Columns from 0.01 to 73,000 entered the network unscaled. Standardized on the training rows: test accuracy 0.985 instead of 0.557, andesite recall 0.939 instead of 0.

Case 3: a swarm detector at 98% accuracy

Data one volcano station, 7983 windows of 30 s (66.5 h), 183 earthquakes
Split in time: 50% training, 25% validation, last 16.6 h test
Model small convolutional network, fires at probability ≥ 0.5
Claim “test accuracy 0.98, ready for the observatory”

Case 3: what went wrong

Earthquakes are 2.3% of the windows, and calling every window noise lowers the loss most. Weighted loss, threshold 0.44 set on validation: 40 of 42 found, 18.8 false alarms per day.

Case 4: beats persistence, until it does not

Data daily east position of a station moving 12 mm/yr, 2015-2024
Split train 2015-21, validation Apr/Aug/Dec 2015-21, test 2022-24
Model last 30 days → 32 → 32 → tomorrow, tanh
Claim validation MAE 1.34 mm, persistence 1.44 mm

Case 4: what went wrong

Test positions lie above every position seen in training. Forecasting the daily change: test MAE 1.31 mm (persistence 1.53, researcher 8.57), 2024/2022 ratio 1.02.

Case 5: the training loss climbs back up

Data 3000 igneous rocks, 9 measurements, 3 rock types (synthetic)
Split random, 2250 training / 750 validation
Model 9 → 64 → 64 → 3, Adam 0.001, 30 epochs, own epoch loop
Claim “validation 0.939, below logistic regression (0.951)”

Case 5: the researcher’s epoch loop

def c5_researcher_epoch(model, opt, criterion, X, y, batch_size, g):
    order = torch.randperm(len(X), generator=g)
    for i in range(0, len(X), batch_size):
        idx = order[i:i + batch_size]
        loss = criterion(model(X[idx]), y[idx])
        loss.backward()
        opt.step()

Compare it with the loop you wrote in 4.7 section 2.4: one update per batch, from the loss of that batch.

Case 5: what went wrong

No opt.zero_grad(): each update used the sum of all gradients since the start. Fixed: validation 0.953, last training loss 0.105.

The five errors

Symptom Cause Check of the fix
1 test 0.97, new events 0.76 windows cut before the split validation ≈ new events
2 every rock called granite unscaled ppm next to wt% test 0.985 against 0.974 (raw-column logistic); andesite recall 0.939
3 0 of 42 earthquakes found rare class, unweighted loss recall, false alarms/day
4 test error grows each year beyond the training range error flat 2022 to 2024
5 loss rises after epoch 5 no opt.zero_grad() the reference run’s curve

This lecture in the literature

✓ Deep ensembles: train the same network from several seeds and use the disagreement of the members as the uncertainty.

Lakshminarayanan, B., Pritzel, A., & Blundell, C. (2017). Simple and scalable predictive uncertainty estimation using deep ensembles. NeurIPS 30.

✓ Monte Carlo (MC) dropout: keep dropout on at prediction time; one trained model gives an uncertainty from repeated passes.

Gal, Y., & Ghahramani, Z. (2016). Dropout as a Bayesian approximation: Representing model uncertainty in deep learning. ICML.

✗ Deep image classifiers state confidences higher than their accuracy; the paper measures the gap on several networks.

Guo, C., Pleiss, G., Sun, Y., & Weinberger, K. Q. (2017). On calibration of modern neural networks. ICML.

📖 Ensembles, dropout and other methods compared on test data shifted away from the training data; deep ensembles did best on most shifted test sets.

Ovadia, Y., et al. (2019). Can you trust your model’s uncertainty? Evaluating predictive uncertainty under dataset shift. NeurIPS 32.

Stated confidence against observed accuracy

5-member ensemble: test accuracy 0.952, ECE 0.010. One MC dropout model: 0.953, ECE 0.017. In the fifth of samples with the largest spread, accuracy is about 0.8 for both.

Error and disagreement past the training range

Error rate: 0.050 in the trained range, 0.076 at 1 to 2 standard deviations, 0.085 beyond. Mean disagreement: 0.011, 0.015, 0.019.

Now run it yourself: resume 4.7 at section 4

  1. Restart the kernel; run sections 1 and 2; continue from section 4
  2. Width and depth (§4); starting weights, learning rate, batch size, early stopping (§5)
  3. §6: the 5-member ensemble and MC dropout; reliability and quintile diagnostics
  4. The out-of-range experiment: find the error the five members agree on, and explain it
  5. §7: the six broken runs; diagnose from the curves before opening the solution

Wed: forecasting shootout (4.9), leaderboard opens · Ch 5 quiz closes Thu Dec 3 · HW-DL due Fri Dec 4