4. Building makemore Part 3: Activations, Gradients, BatchNorm
We dive into some of the internals of MLPs with multiple layers and scrutinize the statistics of the forward pass activations, backward pass gradients, and some of the pitfalls when they are improperly scaled. We also look at the typical diagnostic tools and visualizations you’d want to use to understand the health of your deep network. We learn why training deep neural nets can be fragile and introduce the first modern innovation that made doing so much easier: Batch Normalization. Residual connections and the Adam optimizer remain notable todos for later video.
Links:
- makemore on github:
- jupyter notebook I built in this video:
- collab notebook:
Useful links:
- “Kaiming init“ paper:
- BatchNorm paper:
- Bengio et al. 2003 MLP language model paper (pdf):
- Good paper illustrating some of the problems with batchnorm in practice:
Exercises:
- E01: I did not get around to seeing what happens when you initialize all weights and biases to zero. Try this and train the neural net. You might think either that 1) the network trains just fine or 2) the network doesn’t train at all, but actually it is 3) the network trains but only partially, and achieves a pretty bad final performance. Inspect the gradients and activations to figure out what is happening and why the network is only partially training, and what part is being trained exactly.
- E02: BatchNorm, unlike other normalization layers like LayerNorm/GroupNorm etc. has the big advantage that after training, the batchnorm gamma/beta can be “folded into“ the weights of the preceeding Linear layers, effectively erasing the need to forward it at test time. Set up a small 3-layer MLP with batchnorms, train the network, then “fold“ the batchnorm gamma/beta into the preceeding Linear layer’s W,b by creating a new W2, b2 and erasing the batch norm. Verify that this gives the same forward pass during inference. i.e. we see that the batchnorm is there just for stabilizing the training, and can be thrown out after training is done! pretty cool.
Chapters:
00:00:00 intro
00:01:22 starter code
00:04:19 fixing the initial loss
00:12:59 fixing the saturated tanh
00:27:53 calculating the init scale: “Kaiming init”
00:40:40 batch normalization
01:03:07 batch normalization: summary
01:04:50 real example: resnet50 walkthrough
01:14:10 summary of the lecture
01:18:35 just kidding: part2: PyTorch-ifying the code
01:26:51 viz #1: forward pass activations statistics
01:30:54 viz #2: backward pass gradient statistics
01:32:07 the fully linear case of no non-linearities
01:36:15 viz #3: parameter activation and gradient statistics
01:39:55 viz #4: update:data ratio over time
01:46:04 bringing back batchnorm, looking at the visualizations
01:51:34 summary of the lecture for real this time
20 views
5701
1891
2 days ago 00:24:27 1
Использование Windows 2000 спустя 25 лет
3 weeks ago 00:21:51 1
МЕДВЕЖИЙ ФАРШ • ЖОСКИЙ СМЕРТЕЛЬНЫЙ УРАГАННЫЙ 3D БИЛД ЯРОСТИ ОТЦА БОГА МАТЕРИ • THE WITCHER 3
1 month ago 01:20:21 25
Building an Electric Rover From Scratch - Full Build + Overnight Camping Adventure
1 month ago 03:21:07 1
Doctor Kim Jong-Un Inspects! - Pirated TV from North Korea
1 month ago 00:18:25 1
Dominate in Path of Exile 2 - Gemling Endgame Build
1 month ago 00:08:24 1
Learn Chinese for Beginners | Nationalities in Chinese | Country Names in Chinese
1 month ago 01:02:45 1
You Won’t Believe The ENGINE I’m Putting Into My Russian Buhanka Bread Van! #Буханка #уаз
2 months ago 00:01:16 1
Andor Season 2 - Teaser Trailer | Star Wars & Disney+ | Diego Luna & Ben Mendelsohn (2025)
2 months ago 00:07:41 1
ChatGPT Ethereum Arbitrage Bot: Earn $1,000 Daily in Passive Income
2 months ago 00:26:38 1
How I Designed 3D-Printed Mods for My Vintage Toyota KE25
2 months ago 00:14:30 1
REPUBLICANS MIGHT NEVER LOSE POWER AGAIN!
2 months ago 00:06:03 79
The Witcher 4 - Official Reveal Trailer | The Game Awards 2024
2 months ago 00:05:35 1
Best AliExpress Alternatives for Dropshipping: The Game-Changing Tactics You Need! 🗣
3 months ago 00:23:32 1
Onboard Air Greenland’s Final A330neo flight from Kangerlussuaq
3 months ago 00:23:24 1
СОВРЕМЕННАЯ КЛИНИКА | Speed build | Sims 4
3 months ago 01:13:11 1
The State of Rogue Core (On The Horizon 2024)
3 months ago 00:01:29 1
Тентовые здания МСБИЛДИНГС
3 months ago 00:03:58 1
The Shira Choir x The Kiffness - Im Hashem Lo Yivneh Bayis (Psalm 127 DANCE REMIX)
3 months ago 00:00:31 1
Тот самый чел, который говорит что он “топ 1 холиворлда“
3 months ago 00:06:07 1
PATRIARKH - WIERSZALIN IV (feat. Eliza Sacharczuk) (Official Video) | Napalm Records