Labels: y1=0,y2=1
μbatch=4,σbatch2=5
γ=2.000,β=0.500
ReLU → average per image → linear
| Image | Class 0 | Class 1 |
|---|---|---|
| 1 | 50.0% | 50.0% |
| 2 | 83.2% | 16.8% |
Softmax probabilities
1.239
L=2L1+L2
Two image losses
| Parameter | Before | Gradient | After SGD |
|---|---|---|---|
| γ | 2.000 | 0.261 | 1.974 |
| β | 0.500 | 0.291 | 0.471 |
| [w0,w1] | [0.400, −0.300] | [0.953, −0.953] | [0.305, −0.205] |
| [b0,b1] | [0.000, 0.000] | [0.166, −0.166] | [−0.017, 0.017] |
θnew=θ−η∂θ∂L
η=0.1
θ: scale, offset and classifier parameters
γnew=2.000−0.1×0.261≈1.974
Two images · two values each
μbatch=4
σbatch2=5
Calculate from this batch.
Before scale and offset
a^i=σbatch2+εai−μbatcha^1=5+10−51−4≈−1.342
Training normalizes with the current batch’s mean and variance.
Follow one weight w. Start at w=2.
g=∂w∂Ldata=0.4
Learning rate: η=0.1
wnew=w−ηg
wnew=2−0.1(0.4)=1.96
SGD moves against the gradient. The learning rate scales the update.
Add the same squared-weight penalty. Here, we follow one weight.
J(w)=data lossLdata(w)+L2 penalty2λw2
λ≥0 sets the penalty strength.
∂w∂Ldata=g
∂w∂(2λw2)=λw
∂w∂J=g+λw
wnew=wdata-loss update−ηgL2 contribution−ηλw
The L2 contribution points toward zero and grows with ∣w∣.
Without L2:2−0.04=1.96
ηλw=0.1×0.5×2=0.10
With L2:2−0.04−0.10=1.86
Same starting weight. Same data gradient. L2 contributes an extra −0.10.
Training uses different subsets of activations.
h~i=1−pmihi
1−p: keep probability
Kept: 2/0.5=4
Dropped: 0/0.5=0
An input of 4 becomes 0 or 8, each with 50% chance.
0.5×0+0.5×8=4
Soft targets distribute probability across classes.
qk=(1−ε)yk+Kε
Keep the image; soften its one-hot target.
K=10,ε=0.10
0.91+9×0.01=1.00
Label smoothing and mixing replace one-hot training targets.
GoogLeNet · 22 weighted layers on a longest path · auxiliary heads are used only for training
Average each feature map, then classify: avoid VGG’s large flattened-input FC head.
Efficient depth is one challenge. Next: can we make deeper networks easier to train?
Compute both statistics from the original activations in one channel.
Current batch B
m=2×1×2=4
images × height × width
ai: an original activation
m: number of values in this channel
μB=m1i=1∑mai
μB=41+3+5+7=4
σB2=m1i=1∑m(ai−μB)2
Square each distance from the mean, then average.
σB2=4(1−4)2+(3−4)2+(5−4)2+(7−4)2=5
μB=4,σB2=5
Use the mean and variance just computed for this channel.
μB=4,σB2=5
Shared statistics within this channel.
ε=10−5 keeps the denominator nonzero.
a^i=σB2+εai−μB
Subtract the mean.
Divide by the standard deviation
with ε for stability.
For the first activation, a1=1:
a^1=5+10−51−4≈−1.342
Mean=0
Variance≈1
Learn one scale γ and one offset β per channel.
Input to the affine step
Example: γ=2
γ⋅a^i=2×a^i
Example: β=0.5
aout,i=γ⋅a^i+β
Output mean=0.5; variance≈4
Loss → backpropagation → update γ and β
224×224 input · repeat a residual block within each spatial stage.
Factor spatial filtering from channel mixing · one spatial filter per input channel
Searched B0 baseline: MBConv + SE channel gating · compound scaling comes next
Predict class 0 or class 1.
Synthetic two-moons data
p=P(class 1∣x1,x2)
80 training points
Learn the parameters.
600 validation points
Measure performance on new points.
p≥0.5: predict class 1.
p<0.5: predict class 0.
The boundary is where p=0.5.
J=Ldata
J: objective minimized during training
Ldata: mean training binary cross-entropy
R=21j∑wj2
wj: one network weight
R: half the sum of squared weights
Chosen before training.
Larger values give the penalty more weight.
Controls the size of each update.
Same data and starting parameters · only λ changes
Full-batch gradient descent · η=0.1 · 12,000 updates
Without L2:2−0.04=1.96
ηλw=0.1×0.5×2=0.10
With L2:2−0.04−0.10=1.86
Same starting weight. Same data gradient. L2 contributes an extra −0.10.
DeiT-B · published ImageNet results · 300-epoch comparison
AdamW · Mixup · CutMix
Label smoothing · stochastic depth
Same basic ViT encoder
A strong recipe already helps. The optional teacher adds supervision during training.
The current course measurements compare the MLP and small CNN; ViT remains unmeasured.
Next: compare the architectures, then examine the existing CIFAR-10 validation evidence.
The main distinction is how image positions exchange information.
| Family | Representation | Spatial interaction | Built-in structure |
|---|---|---|---|
| MLP | Flattened pixels | Dense connections across positions | Position-specific weights |
| CNN | Spatial feature maps | Local filters shared across the image | Locality and translation structure |
| ViT | Patch tokens and positions | Attention weights depend on token content | Patch structure and shared token operations |
CNN depth expands context. ViT attention can connect all patches in each block.
Compare trained recipes on the task and device that matter.
Macro averages weight classes equally.
| Average | What receives equal weight? | Precision | Recall | F1 |
|---|---|---|---|---|
| macro | Each class | 75.6% | 75.6% | 75.5% |
| weighted | Each image through class support | 75.6% | 75.6% | 75.5% |
| micro | All classification decisions pooled | 75.6% | 75.6% | 75.6% |
Equal class support makes macro and weighted averages identical here.
Single-label classification, all classes:
micro precision=micro recall=micro F1=accuracy
CIFAR-10 · 5,000 validation images · CNN
Macro F1 averages the per-class F1 scores.
CIFAR-10 · 5,000 validation images · CNN
Correct if the true class is in the selected shortlist.
CIFAR-10 · 5,000 validation images · CNN · one versus rest
Lower thresholds can increase recall and false positives.
CIFAR-10 · 5,000 validation images · CNN
Calibrated confidence matches observed accuracy.
CIFAR-10 · 50,000 training images · 10,000 test images
Same architecture · 150 epochs · no data augmentation
+3.8 percentage points in test accuracy