Homework — does it really help?
In step 6 I said dropout + weight decay "do not raise validation accuracy in a way you would notice". Do not believe it — check it.
Write a new file seeds.py that, for two settings — baseline (dropout=0,
weight_decay=0) and dropout=0.3, weight_decay=1e-4 — and three seeds (0, 1, 2),
trains an MLP (256, 256): 10 000 training images, 5 000 validation, 30 epochs, Adam
lr=0.001, no early stopping. For each setting print the training accuracies, the
validation accuracies and the validation mean.
Details that matter:
torch.manual_seed(seed)before each training, and build the model after it;- measure the accuracies with
evaluateafterfit; fitprints a line per epoch — silence it (verbose=False).
My machine (it takes ~6 min — 6 trainings of 30 epochs, and that is normal):
baseline train 95.8% 97.3% 97.0% val 85.8% 87.3% 86.9% mean val 86.7%
dropout 0.3 + wd 1e-4 train 93.1% 92.7% 94.0% val 86.7% 86.2% 87.7% mean val 86.9%
Answer three questions in writing, one sentence each:
- Is training accuracy systematically lower with regularisation? (Is that visible in all three seeds?)
- Is the difference of the validation means larger than the difference between seeds within the same row?
- What number would you tell a friend if they asked "how accurate is your model"?
The third question is the most important. My answer would be: "about 86–87 % — and I would not try to be more precise, because runs differ by up to 1.5 points".
Your numbers may differ by a few tenths — what matters is that you answer 1 and 2 from what you see, not from my table.