Batch Norm i Layer Norm
Stabilizować aktywacje, aby trenować głębsze sieci
Batch Norm i Layer Norm to bezpłatna lekcja Deep Learning Academy na CoddyKit. To lekcja 3 z 4. Możesz przeczytać całą lekcję poniżej za darmo — a potem ćwiczyć ją interaktywnie w przeglądarce z wbudowanym edytorem kodu i tutorem AI dostępnym 24/7. To część ścieżki edukacyjnej Deep Learning Academy, a Twój postęp synchronizuje się między webem a aplikacją CoddyKit. Kurs Deep Learning Academy zawiera 4 lekcji w sumie.
Części tej lekcji nie zostały jeszcze przetłumaczone i są wyświetlane po angielsku.
Why Normalize Activations
As signals flow through layers, their scale drifts and training slows. Normalization keeps activations in a stable, well-behaved range. ⚖️
Batch Norm in One Line
Batch normalization rescales each feature using the mean and variance computed across the current mini-batch.
Add Batch Norm
You drop in a batch norm layer after a linear or conv layer. Use nn.BatchNorm1d for dense features and BatchNorm2d for images.
self.bn = nn.BatchNorm1d(128)
x = torch.relu(self.bn(self.fc(x)))Learnable Scale and Shift
Batch norm adds two trainable parameters, gamma and beta, so the network can rescale and shift the normalized output as it needs.
It Lets You Train Deeper
By steadying activations, batch norm allows higher learning rates and deeper networks that would otherwise be hard to train.
Train vs Eval Stats
During training, batch norm uses batch statistics; at eval it switches to running averages, so call model.eval() before testing.
Batch Size Matters
Batch norm depends on the batch. With very small batches the statistics get noisy and the benefit can disappear.
Enter Layer Norm
Layer normalization normalizes across the features of a single sample, so it does not depend on the batch at all.
Add Layer Norm
Layer norm shines in transformers and RNNs. You add it with nn.LayerNorm, passing the size of the features to normalize.
self.ln = nn.LayerNorm(256)
x = self.ln(x)Same Behavior Both Modes
Because layer norm uses per-sample statistics, it behaves the same in training and eval, which suits variable batch sizes.
Which One to Pick
Reach for batch norm in conv vision models and layer norm in sequence and transformer models, where batches and lengths vary.
Quick Check
Recall the key difference between the two normalization styles.
Recap
You compared normalization: batch norm uses batch statistics and helps CNNs, while layer norm works per-sample and powers transformers. 🚀
Często zadawane pytania
Czy lekcja „Batch Norm i Layer Norm” jest bezpłatna?
Tak — pełny tekst „Batch Norm i Layer Norm” jest dostępny za darmo tutaj w sieci. Aby ćwiczyć ją interaktywnie (wbudowany edytor kodu i tutor AI dostępny 24/7) i odblokować resztę kursu Deep Learning Academy, przejdź na CoddyKit PRO. Kurs Deep Learning Academy zawiera 4 lekcji w sumie.
Co nauczysz się w „Batch Norm i Layer Norm”?
Stabilizować aktywacje, aby trenować głębsze sieci Ćwiczysz Deep Learning Academy z praktycznym kodem, który uruchamiasz bezpośrednio w przeglądarce, a tutor AI dostępny 24/7 odpowiada na Twoje pytania podczas pracy nad lekcją.
Czy potrzebuję doświadczenia, aby zacząć Deep Learning Academy?
Nie wymagamy żadnego doświadczenia. Deep Learning Academy w CoddyKit jest strukturyzowany dla początkujących i zaawansowanych użytkowników, więc możesz zacząć tutaj lub od początku i uczyć się w swoim tempie. To lekcja 3 z 4.
Ile czasu zajmuje lekcja „Batch Norm i Layer Norm”?
Większość lekcji CoddyKit trwa około 5–10 minut. Każda lekcja to mały, interaktywny krok, dzięki czemu robisz systematyczne postępy i zawsze wracasz dokładnie do tego samego miejsca — na webie i w aplikacji.
Czy mogę pisać i uruchamiać kod w tej lekcji Deep Learning Academy?
Tak. Każda lekcja Deep Learning Academy zawiera wbudowany edytor kodu, więc piszesz i uruchamiasz prawdziwy kod bezpośrednio w przeglądarce i od razu otrzymujesz sprzężenie zwrotne od AI — bez konfiguracji na komputerze.
Wszystkie lekcje w tym kursie
- Odczytywanie luki między train a val
- Dropout: losowe wyłączanie neuronów
- Batch Norm i Layer Norm
- Augmentacja danych jako darmowe dane