03 / 14 · Training Neural Networks
Losses and regularization
Which loss to train with and how its gradient behaves, why cross-entropy must be computed from logits through a stable log-softmax, label smoothing, how deep networks memorize, and how weight decay, dropout, early stopping and augmentation narrow the gap between training and validation.
PyTorch and automatic differentiation · Logistic regression · Regularization
On this page 8
The previous note built a training pipeline and used cross-entropy in it without asking why. Two parts of that pipeline decide what the network actually learns. The loss says what counts as a good prediction, and through its gradient it decides how hard each example pulls on the weights. Regularization decides what happens once the network can fit its training set exactly, which a deep network almost always can: whether it then fits the signal or memorizes the noise. This note covers both: losses for regression and classification and how their gradients behave, the numerically stable way to compute cross-entropy, label smoothing, and the four standard regularizers of deep networks, ending with an experiment in which they close the gap between training and validation accuracy.
Notation. For one example, is the network’s output; for regression the residual is . For classification into classes the network outputs logits , the softmax turns them into probabilities , and is the one-hot vector of the true class . are the parameters, the learning rate, a weight-decay coefficient, the dropout probability and the label-smoothing coefficient.
Baseline: the loss is a negative log-likelihood#
The choice of loss was made in the Machine Learning course, and it carries over unchanged. The network outputs the parameters of a distribution for , and the loss is the negative log-likelihood of the observed under it (output layers and losses): a Gaussian mean gives the squared error, a Bernoulli logit the binary cross-entropy of logistic regression, logits the softmax cross-entropy. Why a smooth surrogate replaces the error count is in the linear classifiers note. This note does not repeat those derivations. It asks the questions that matter once the loss drives a deep network through millions of gradient steps: how the gradient of each loss behaves, how to compute it without overflow, and how to keep the network from fitting its training set too well.
Regression: what a large residual costs#
Three losses are common, written per example in terms of the residual :
The last is the Huber loss with threshold . Backpropagation starts from their derivatives with respect to the prediction:
The squared error pulls in proportion to the residual, the absolute error with a constant force, and the Huber loss like the squared error near zero and like the absolute error beyond . In a deep network the size of this first factor matters twice: it decides how much each example contributes to the step, and a single huge residual can produce a gradient large enough to throw every layer off at once.
Worked example. A batch with residuals , the last one an outlier. Averaged over the batch, the squared error is , the absolute error and the Huber loss with is . The per-example derivatives are , and . Under the squared error the outlier supplies of the total in absolute value, 80% of the push on the weights; under Huber it supplies of .
Regression losses and their derivatives
Which loss is right depends on the noise, as the least-squares note explains: squared error estimates a conditional mean and is optimal for Gaussian noise, absolute error a median, and Huber is a compromise that stays efficient on clean data and caps the influence of outliers in . In PyTorch they are nn.MSELoss, nn.L1Loss and nn.HuberLoss(delta); nn.SmoothL1Loss(beta) is the Huber loss divided by , the form used for box coordinates in Object detection.
Classification: cross-entropy from logits#
For classes the loss is the negative log-probability of the true class,
with the gradient derived in the backpropagation note. Each logit’s gradient lies between and , whatever the logits are: unlike the squared error, cross-entropy cannot produce an exploding first factor. What it can produce is an overflow, if it is computed in the obvious way.
Why log-softmax is numerically stable#
The obvious way computes the probabilities first, , and then takes . Both steps fail in floating point. The exponential overflows: in 32-bit arithmetic the largest number is about , so any logit above gives and the ratio is not a number. And the probability underflows: a class whose logit lies far below the largest one gets , and .
The trick is to never form . Subtract the largest logit before exponentiating, and stay in log space:
It is the same quantity: , and factoring out of every term of the sum gives the boxed form, the log-sum-exp identity of the conditioning note of the Mathematics for Machine Learning course. It is also safe: every exponent is at most 0, so no exponential overflows; the term with contributes exactly 1, so the sum lies between 1 and and its logarithm between 0 and , never . Very negative exponents may still underflow to 0, but they are added to a sum that is at least 1, where they would not have counted anyway. This is F.log_softmax, and F.cross_entropy and nn.CrossEntropyLoss apply it to raw logits internally.
Worked example in 32-bit arithmetic. Take the logits with true class 3. The exact loss is to many digits.
- Exponentiate, normalize, log. overflows to , and .
- Shift, then normalize, then log. . Now is below the smallest normal 32-bit number () and survives only as a subnormal number with a few significant bits, and is below even the smallest subnormal, , so it becomes 0. The logarithms of the probabilities come out as : the middle one is off by , and the loss for class 3 is infinite. Its gradient is not a number in all three coordinates.
- Log-softmax. exactly as printed in 32-bit, loss , gradient .
The error of the computed loss in 32-bit arithmetic
The rule that follows: pass logits, not probabilities, to the loss. A model that ends with nn.Softmax followed by torch.log and nn.NLLLoss is correct in exact arithmetic and fails on confident predictions. The same holds for two classes, where BCEWithLogitsLoss is the stable form of a sigmoid followed by BCELoss.
Label smoothing#
Cross-entropy with a one-hot target is never satisfied. Its minimum, 0, is reached only at , that is, at an infinite gap between the true logit and the others, so on a training set the network can fit perfectly it keeps growing its logits for as long as it trains. Label smoothing (Szegedy et al., 2016, section 7) replaces the one-hot target by a mixture with the uniform distribution,
The second form reads as the usual loss plus a penalty, with weight , on the average negative log-probability over all classes, which grows when any class is pushed to probability 0. The gradient becomes , which vanishes at : the target is now reachable, at a finite gap.
Worked example. With and the target puts on the true class and on each of the other nine. If the true logit is and the others are 0, then , each other , and the loss is
Its derivative vanishes at , so the best gap is , where and the loss equals the entropy of , . Past the optimum the loss grows again, with slope approaching : at it is and at it is , while the plain cross-entropy at those gaps is and .
Label smoothing makes the optimum finite
With on ImageNet’s 1000 classes, label smoothing lowered the top-1 and top-5 errors of an Inception network by about 0.2 percentage points each (Szegedy et al., 2016, section 7 and Table 3), and the original Transformer used it with (Vaswani et al., 2017, section 5.4). It also tends to make predicted probabilities better calibrated, but a teacher network trained with it transfers less to a student by distillation (Müller, Kornblith and Hinton, 2019), which matters in Model compression. In PyTorch it is the label_smoothing argument of nn.CrossEntropyLoss, with the same as above.
Overfitting in deep networks#
The Machine Learning course defined overfitting as a model fitting its training data, noise included, at the expense of new data. Deep networks push this to the extreme. Zhang et al. (2017) trained standard image classifiers with the labels replaced by random ones. On CIFAR-10 the networks reached zero training error anyway, with training slowed only by a small constant factor, and on ImageNet an Inception network fitted a million random labels to 95.2% training accuracy; test accuracy was, of course, at chance (section 2.1). With only part of the labels corrupted, the networks still fitted the training set perfectly, and the test error grew with the fraction of corrupted labels. Their capacity is enough to memorize a whole dataset, so the training error alone says nothing about what a network has learned. Explicit regularization helped generalization in their experiments but was “neither necessary nor by itself sufficient” to control it (sections 1.1 and 3).
Worked example. The network of the Code section, trained on 300 bundled digit images whose labels are all drawn at random, reaches training accuracy and validation accuracy , close to the of guessing. With the true labels, except that 58 of the 300 were redrawn at random so that 55 are now wrong, the same network again fits all 300 training labels, including all 55 wrong ones, and classifies of 1497 clean validation images correctly. The difference between training and validation accuracy, the generalization gap, is , and the validation loss, , is far above the training loss, .
Regularization#
The Training deep networks note of the Machine Learning course derives the main regularizers; here they are as they appear in a PyTorch training loop, with what each one does to the step.
Weight decay#
Adding to the loss adds to the gradient, and a gradient step becomes
Before the usual step, every weight is multiplied by , hence the name weight decay. A weight that the data do not support shrinks geometrically towards 0; one the data need is held up by its gradient. This is the ridge penalty of linear models, applied to every layer. Worked example. With and , each step multiplies a weight by ; a weight with zero gradient falls from 1 to in 1000 steps. AlexNet used with momentum 0.9, and its authors found that this small decay lowered even the training error (Krizhevsky, Sutskever and Hinton, 2012, section 5).
In PyTorch it is the weight_decay argument of the optimizer. For SGD it adds to the gradient, which is the formula above. For Adam it does the same, but Adam then divides the whole gradient by a per-weight scale, so weights with large gradients are decayed less; AdamW applies the decay outside the adaptive step instead, so that every weight shrinks by the same factor (Loshchilov and Hutter, 2019). The Machine Learning course works out the difference, and Optimizing deep networks returns to it with the other optimizers. Biases and the scales of normalization layers are usually excluded from decay.
Dropout#
Dropout (Srivastava et al., 2014) adds noise to the forward pass during training. Each unit of a layer is zeroed with probability , independently for every example and every step, and the survivors are scaled up:
The scaling, called inverted dropout, keeps the expectation: . At test time dropout is switched off and the layer passes unchanged, so the next layer sees inputs of the same average size in training and at test. The original paper instead kept units with probability , did not scale during training, and multiplied the weights by at test time; the two forms are equivalent in expectation, and PyTorch’s nn.Dropout(p) uses the inverted form with the probability of dropping.
Worked example. For and , the mask gives : the surviving units are doubled. Averaged over 100,000 masks, comes out as , equal to up to sampling noise. In evaluation mode the layer returns .
Inverted dropout in training and at test time
- Draw a mask: each unit is kept with probability , independently.
- Multiply: dropped units become 0.
- Rescale the survivors by , so that each unit keeps its expected value.
- At test time (
model.eval()), skip all three: the layer is the identity.
Why the noise helps: a unit cannot rely on any particular other unit being present, so the network cannot build fragile co-adaptations that only fit the training set. The Machine Learning course shows two exact readings of it, as training an ensemble of thinned networks that share weights and, for a linear model, as an L2 penalty scaled by the size of each input (dropout). Typical rates are on large fully connected layers, as in AlexNet, and in Transformers.
Early stopping#
Training longer lowers the training loss but, once the network starts fitting noise, raises the validation loss. Early stopping evaluates on validation data after each epoch, keeps the parameters with the lowest validation loss, and stops when it has not improved for a set number of epochs. It costs nothing but the evaluation, and the number of steps acts like an L2 penalty that weakens as training goes on; the Machine Learning course states the correspondence and shows it on noisy digits. Since the validation set is then used to choose, the final accuracy must be measured on a separate test set.
Data augmentation#
When some transformations of the input do not change its label, such as small shifts, crops, flips and colour changes of a photograph, train on transformed copies. Each epoch the network sees a fresh random , and the training loss becomes an average over transformations,
which the network cannot drive to zero by memorizing fixed inputs. Augmentation is regularization by prior knowledge: the transformations encode what the label does not depend on, and a wrong transformation, such as a flip that turns a “b” into a “d”, teaches the wrong invariance. AlexNet trained on random crops of images and their mirror images (Krizhevsky, Sutskever and Hinton, 2012, section 4.1); the Machine Learning course measures what one-pixel shifts do for digits, and Self-supervised learning turns augmentations into the training signal itself.
An experiment: narrowing the gap#
The setting is the one of the worked example: 300 training digits with 58 labels redrawn at random (55 of them now wrong), 1497 validation digits with clean labels, a network trained with AdamW at learning rate , batches of 32, for 200 epochs, and four configurations. Weight decay uses in AdamW, a shrinkage of per step, and dropout uses after both hidden layers. Each row averages three seeds:
| configuration | training accuracy | validation accuracy | gap | training loss | validation loss | wrong labels fitted |
|---|---|---|---|---|---|---|
| none | 1.000 | 0.807 | 0.193 | 0.005 | 0.914 | 1.000 |
| weight decay | 0.979 | 0.842 | 0.137 | 0.161 | 0.570 | 0.885 |
| dropout | 0.989 | 0.843 | 0.146 | 0.049 | 0.579 | 0.939 |
| both | 0.887 | 0.881 | 0.006 | 0.384 | 0.501 | 0.400 |
Training accuracy is measured against the noisy labels the network was trained on, and “wrong labels fitted” is the fraction of the 55 wrong training labels that the network reproduces. Without regularization it reproduces all of them. Each regularizer alone lowers the training accuracy a little, memorizes fewer wrong labels and raises the validation accuracy by about 3.5 points. Together they stop most of the memorization: the network reproduces only 40% of the wrong labels, the gap all but closes, and validation accuracy rises to . The validation loss falls from to .
Regularization narrows the gap between training and validation
Two cautions on reading the table. The strengths were chosen from a coarse grid (, ) on this same validation set, so the validation numbers are slightly optimistic; an unbiased estimate would need a separate test set. And a closed gap is not the goal in itself: the goal is the validation accuracy, and a heavily regularized model can have no gap and be poor on both sets.
What changed#
| Plain training | With the tools of this note | |
|---|---|---|
| Regression loss | squared error, gradient grows with the residual | Huber when outliers are expected, gradient capped at |
| Classification loss | softmax, then log | log-softmax on logits: no overflow, finite gradients |
| Target | one-hot, logits grow without bound | smoothed, optimal gap |
| Noisy labels | memorized (55 of 55 here) | 40% memorized with weight decay and dropout |
| Validation accuracy here | 0.807 | 0.881 |
Limitations#
- Losses encode assumptions. Squared error assumes light-tailed noise; cross-entropy assumes the labels are right. With systematically wrong labels, no loss recovers the truth.
- Stable formulas only where they are used. Log-softmax protects the loss; a softmax computed elsewhere in the model, for example for attention weights, needs the same max-subtraction, which library functions do but hand-written code may not.
- Label smoothing changes the logits. Smoothed models are less useful as teachers for distillation, and their probabilities are shrunk towards uniform by design.
- Regularization strengths are hyperparameters. They are chosen on validation data, they interact (weight decay with the learning rate and the optimizer, dropout with batch normalization), and the best values change with the size of the data.
- Memorization is not explained by these tools. Networks trained without any explicit regularization often generalize well; why is still an open question, and the experiment above shows only that the tools help when labels are noisy and data are few.
What you should remember#
- The loss is the negative log-likelihood of an output distribution; its derivative with respect to the prediction is the first factor of every gradient: , or for regression, for cross-entropy.
- Compute cross-entropy from logits: . In 32-bit arithmetic overflows above and rounds to 0 below .
- Label smoothing with replaces by ; the optimal logit gap becomes finite, for , .
- Deep networks can memorize random labels; training accuracy alone says nothing.
- Weight decay multiplies weights by per step (use AdamW with Adam); dropout zeroes units with probability and scales survivors by , only in training mode; early stopping and augmentation regularize through time and data.
- On noisy digits, weight decay and dropout together cut memorized wrong labels from 100% to 40% and raise validation accuracy from 0.807 to 0.881.
Code#
Regression losses and their gradients, cross-entropy in 32-bit arithmetic, label smoothing, inverted dropout, weight decay as shrinkage, and the experiment of the last section. Seeds are fixed; exact numbers can differ slightly across platforms and library versions. The script runs in about 20 seconds on a laptop CPU, almost all of it in the experiment.
Data. Optical Recognition of Handwritten Digits, E. Alpaydin and C. Kaynak (1998), UCI Machine Learning Repository, CC BY 4.0. Loaded through scikit-learn; the transformations used in this example are specified in the code.
import math, numpy as np, torch
from torch import nn
import torch.nn.functional as F
from sklearn.datasets import load_digits
from sklearn.model_selection import train_test_split
# 1. regression losses on the residuals (0.5, -2, 10): value and gradient with respect to each prediction
r = torch.tensor([0.5, -2.0, 10.0], requires_grad=True)
for name, loss_fn in [('squared', nn.MSELoss()), ('absolute', nn.L1Loss()), ('Huber', nn.HuberLoss(delta=1.0))]:
r.grad = None
loss = loss_fn(r, torch.zeros(3))
loss.backward()
print(name, round(loss.item(), 4), (r.grad * 3).tolist()) # gradient times n = 3: per example
# squared 34.75 [1.0, -4.0, 20.0] | absolute 4.1667 [1.0, -1.0, 1.0] | Huber 3.7083 [0.5, -1.0, 1.0]
# 2. cross-entropy from logits in float32: z = (100, 0, -20)
z = torch.tensor([100.0, 0.0, -20.0])
naive = torch.exp(z) / torch.exp(z).sum()
shifted = torch.exp(z - z.max()) / torch.exp(z - z.max()).sum()
r3 = lambda v: [round(x, 3) for x in v.tolist()]
print(r3(naive), r3(torch.log(shifted)), r3(F.log_softmax(z, dim=0)))
# [nan, 0.0, 0.0] [0.0, -99.983, -inf] [0.0, -100.0, -120.0]
for name, f in [('log of softmax', lambda t: -torch.log(torch.softmax(t, 0))[2]),
('cross_entropy', lambda t: F.cross_entropy(t[None], torch.tensor([2])))]:
t = z.clone().requires_grad_()
loss = f(t)
loss.backward()
print(name, loss.item(), r3(t.grad))
# log of softmax inf [nan, nan, nan] | cross_entropy 120.0 [1.0, 0.0, -1.0]
# 3. label smoothing, K = 10, eps = 0.1: the best logit gap is log(0.91 / 0.01) = log 91, and the loss there is H(q)
K, eps = 10, 0.1
q = torch.full((K,), eps / K); q[0] += 1 - eps
gap = math.log(q[0].item() / q[1].item())
best = torch.zeros(K); best[0] = gap
best.requires_grad_()
loss = F.cross_entropy(best[None], torch.tensor([0]), label_smoothing=eps)
loss.backward()
print(round(gap, 3), round(loss.item(), 4), round(-(q * q.log()).sum().item(), 4), round(best.grad.abs().max().item(), 6))
# 4.511 0.5003 0.5003 0.0
for g in (2.0, 4.511, 8.0, 16.0):
zz = torch.zeros(1, K); zz[0, 0] = g
print(g, round(F.cross_entropy(zz, torch.tensor([0])).item(), 4), round(F.cross_entropy(zz, torch.tensor([0]), label_smoothing=eps).item(), 4))
# 2.0 0.7966 0.9766 | 4.511 0.0943 0.5003 | 8.0 0.003 0.723 | 16.0 0.0 1.44 (gap, plain, smoothed)
# 4. inverted dropout on h = (2, 0.5, 1, 3) with p = 0.5: one mask, then the average of 100,000 masks
torch.manual_seed(4)
h = torch.tensor([2.0, 0.5, 1.0, 3.0])
drop = nn.Dropout(p=0.5)
print(drop(h).tolist(), [round(v, 2) for v in drop(h.repeat(100_000, 1)).mean(0).tolist()])
# [4.0, 0.0, 2.0, 0.0] [2.0, 0.5, 1.0, 2.99]
drop.eval()
print(drop(h).tolist()) # [2.0, 0.5, 1.0, 3.0]
# 5. weight decay as shrinkage: SGD with weight_decay multiplies a weight with zero loss gradient by (1 - lr * wd) per step
w = nn.Parameter(torch.tensor([1.0]))
opt = torch.optim.SGD([w], lr=0.1, weight_decay=0.01)
for _ in range(1000):
opt.zero_grad()
(w * 0).sum().backward()
opt.step()
print(round(w.item(), 4), round(0.999 ** 1000, 4)) # 0.3677 0.3677
# 6. overfitting and regularization on digits: 300 training images, 20% of their labels replaced at random,
# 1497 validation images with clean labels; a 64 -> 256 -> 256 -> 10 network, AdamW, 200 epochs, 3 seeds
X, y = load_digits(return_X_y=True)
Xtr, Xva, ytr, yva = train_test_split(X / 16.0, y, train_size=300, random_state=0, stratify=y)
Xtr, Xva, ytr, yva = (torch.tensor(Xtr, dtype=torch.float32), torch.tensor(Xva, dtype=torch.float32),
torch.tensor(ytr), torch.tensor(yva))
rng = np.random.default_rng(0)
noisy = ytr.clone()
flip = torch.tensor(rng.random(300) < 0.2)
noisy[flip] = torch.tensor(rng.integers(0, 10, int(flip.sum())))
wrong = noisy != ytr
print(int(flip.sum()), int(wrong.sum())) # 58 55: 58 labels redrawn, 55 of them now wrong
def run(labels, p, wd, seed):
torch.manual_seed(seed)
model = nn.Sequential(nn.Linear(64, 256), nn.ReLU(), nn.Dropout(p),
nn.Linear(256, 256), nn.ReLU(), nn.Dropout(p), nn.Linear(256, 10))
opt = torch.optim.AdamW(model.parameters(), lr=1e-3, weight_decay=wd)
loader = torch.utils.data.DataLoader(torch.utils.data.TensorDataset(Xtr, labels), batch_size=32, shuffle=True)
model.train()
for epoch in range(200):
for xb, yb in loader:
opt.zero_grad()
F.cross_entropy(model(xb), yb).backward()
opt.step()
model.eval()
with torch.no_grad():
ztr, zva = model(Xtr), model(Xva)
return np.array([(ztr.argmax(1) == labels).float().mean(), (zva.argmax(1) == yva).float().mean(),
F.cross_entropy(ztr, labels), F.cross_entropy(zva, yva),
(ztr.argmax(1)[wrong] == noisy[wrong]).float().mean()])
# random labels: memorized all the same
rand = torch.tensor(rng.integers(0, 10, 300))
print(run(rand, 0.0, 0.0, 0)[:2].round(3)) # [1. 0.124]: training and validation accuracy
print(' train acc val acc gap train loss val loss wrong labels fitted')
for name, p, wd in [('none', 0.0, 0.0), ('weight decay', 0.0, 1.0), ('dropout', 0.5, 0.0), ('both', 0.5, 1.0)]:
m = np.mean([run(noisy, p, wd, s) for s in range(3)], axis=0)
print(f'{name:12} {m[0]:9.3f} {m[1]:8.3f} {m[0] - m[1]:5.3f} {m[2]:11.3f} {m[3]:9.3f} {m[4]:9.3f}')
# train acc val acc gap train loss val loss wrong labels fitted
# none 1.000 0.807 0.193 0.005 0.914 1.000
# weight decay 0.979 0.842 0.137 0.161 0.570 0.885
# dropout 0.989 0.843 0.146 0.049 0.579 0.939
# both 0.887 0.881 0.006 0.384 0.501 0.400
Next#
The experiment trained a network of three layers. Deeper networks run into a problem that no loss or regularizer fixes: the scale of the signals and of the gradients changes from layer to layer, so that after a few dozen layers activations explode or vanish before training even starts. The next note shows how to choose the initial weights so that the scale is preserved, and how normalization layers keep it under control during training.
References#
- C. Szegedy, V. Vanhoucke, S. Ioffe, J. Shlens, Z. Wojna. Rethinking the Inception architecture for computer vision. CVPR, 2016. Section 7 (label smoothing), Table 3.
- R. Müller, S. Kornblith, G. Hinton. When does label smoothing help? NeurIPS, 2019.
- A. Vaswani et al. Attention is all you need. NeurIPS, 2017. Section 5.4 (label smoothing).
- N. Srivastava, G. Hinton, A. Krizhevsky, I. Sutskever, R. Salakhutdinov. Dropout: a simple way to prevent neural networks from overfitting. Journal of Machine Learning Research, 15:1929–1958, 2014.
- A. Krizhevsky, I. Sutskever, G. E. Hinton. ImageNet classification with deep convolutional neural networks. NeurIPS, 2012. Section 4.1 (augmentation), section 4.2 (dropout), section 5 (weight decay).
- I. Loshchilov, F. Hutter. Decoupled weight decay regularization. ICLR, 2019.
- C. Zhang, S. Bengio, M. Hardt, B. Recht, O. Vinyals. Understanding deep learning requires rethinking generalization. ICLR, 2017. Section 2 (fitting random labels), section 3 (explicit regularization).
- P. J. Huber. Robust estimation of a location parameter. Annals of Mathematical Statistics, 35(1):73–101, 1964.
- IEEE. IEEE standard for floating-point arithmetic, IEEE 754-2019. The binary32 format: largest finite number, smallest normal and subnormal numbers.
- I. Goodfellow, Y. Bengio, A. Courville. Deep Learning. MIT Press, 2016. Section 4.1 (overflow and underflow, the stable softmax), section 6.2.2.3 (softmax units), sections 7.1, 7.4, 7.8 and 7.12 (weight decay, augmentation, early stopping, dropout).
- A. Zhang, Z. C. Lipton, M. Li, A. J. Smola. Dive into Deep Learning. Cambridge University Press, 2023. Section 3.7 (weight decay), section 4.5 (softmax revisited: the log-sum-exp trick), section 5.6 (dropout).
- S. J. D. Prince. Understanding Deep Learning. MIT Press, 2023. Chapter 5 (loss functions), chapter 9 (regularization).
- Глубинное обучение 1 (Deep Learning 1), Faculty of Computer Science, HSE University. Course materials, repository xiyori/intro-to-dl-hse, branch 2025-2026: lecture 2 (the cross-entropy loss, label smoothing, dropout).