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
3 views
5686
1889
10 months ago 00:10:02 1
First TSUNAMI in Japan! Earthquake М7.6 and more than 21 Tremors M5 hit Ishikawa, Honshu.
10 months ago 00:08:02 1
40 earthquakes M7.6, M6.1, M5.7 occurred in Japan in 2 hours! 300 km tsunami warning
10 months ago 00:18:05 1
M7.6 Earthquake & Tsunami Hit Japan January 1, 2024
10 months ago 00:06:11 1
Child Of The Cold War Vs Soviet Star | How Does F-16 Compare To Russia’s MiG-29? | Ukraine War
10 months ago 00:00:12 3
At ghaziabad tallest building in ghaziabad City(720P_HD).mp4
10 months ago 00:37:50 1
Front End System Design Fundamentals (All In One Comprehensive Guide)
10 months ago 00:01:00 1
POV: You make main bus in factorio V2
10 months ago 00:00:00 1
🔴 LIVE Прославление | Церковь Божия Music
10 months ago 00:12:31 1
Mastering Blog Commenting | A Step-by-Step Guide for SEO Backlinks|What is blog commenting backlinks
10 months ago 00:05:08 1
Tai Chi Meditation: Calm Your Mind And Strong Your Body | Taichi Zidong
10 months ago 00:07:13 1
Boxing Workouts to Help You Knock Out Fat
10 months ago 00:19:04 1
Abandoned 1978 Citroën 2cv4 Full Restoration Project
10 months ago 00:31:39 1
Minecraft | How to Build a Japanese House
10 months ago 00:00:15 1
Дмитрий Голубочкин ругаться матом #gym #bodybuilding #качалка
10 months ago 00:08:04 1
2 minutes ago in Japan! Destruction after earthquake and tsunami in Ishikawa
10 months ago 00:00:56 1
Дмитрий Голубочкин очень сильно похудел #качалка #мотивация #накачаться #bodybuilding #стараяшкола
10 months ago 00:21:59 14
[Outdoor Boys] Survival Camping in 12 ft (4 m) of Snow During a Blizzard
10 months ago 00:25:24 1
Тест всех небюджетных видеокарт (и новинок - RX7600, RX7700XT, RTX4060, RTX4060Ti, RTX4070).
10 months ago 00:23:06 1
RTX 3070 vs RX 6750 XT | R5 5600X | Tested in 15 games
10 months ago 00:02:27 1
Captain America 4 : NEW WORLD ORDER (2024) | Teaser Trailer Concept (2023) | Marvel Studios
10 months ago 00:04:02 1
China in Ruins: Earthquake M6.2 Destroyed more than 5,000 Buildings in Gansu province.
10 months ago 00:12:21 1
Etzinger Etz-I Coffee Grinder Review
10 months ago 00:06:23 1
Video Overview | Kinu M47 Phoenix Manual Coffee and Espresso Grinder
10 months ago 00:08:03 3
Just now, building collapse in China as 6.2 earthquake shakes Gansu and Qinghai