Deep Learning Training
Neural-network regularization, dropout at train vs inference, normalization layers (BatchNorm/LayerNorm), gradient accumulation, and set/graph architectures.
21 questions
JuniorTheoryVery commonWhen do you pick ReLU, LeakyReLU, GELU, sigmoid or tanh, and what is dying ReLU?
When do you pick ReLU, LeakyReLU, GELU, sigmoid or tanh, and what is dying ReLU?
ReLU is the cheap default for hidden layers; sigmoid and tanh saturate and belong on outputs and gates. LeakyReLU and GELU keep a nonzero slope for negative inputs, GELU being the transformer default. A dying ReLU sits on negative input — zero out, zero gradient, no recovery.
Common mistakes
- ✗Defaulting to sigmoid in hidden layers and hitting saturation
- ✗Thinking LeakyReLU and GELU also zero the negative side
- ✗Believing a dead ReLU unit recovers on its own later in training
Follow-up questions
- →Which hyperparameter most often causes a whole layer of ReLUs to die?
- →Why is
GELUsmoother than ReLU, and where does that help?
MiddleTheoryVery commonWhat does the optimizer Adam adapt per parameter, and why does tuned SGD with momentum often generalize better?
What does the optimizer Adam adapt per parameter, and why does tuned SGD with momentum often generalize better?
Adam keeps running estimates of the first and second gradient moments per weight and divides the step by the root of the second, so every weight gets its own effective step plus momentum. That converges fast with little tuning, but the rescaling tends toward sharper minima, while tuned SGD with momentum finds flatter ones.
Common mistakes
- ✗Thinking Adam tunes one global learning rate rather than a per-parameter step
- ✗Reversing the update — multiplying by the second moment instead of dividing by its root
- ✗Assuming Adam is strictly better and never trading it for tuned SGD
Follow-up questions
- →How does
AdamWdecouple weight decay, and why is that not the same as L2 in Adam? - →Why does Adam need bias correction in its first few steps?
MiddleTheoryVery commonHow does backpropagation compute gradients through a deep stack, and why does that make deep nets unstable?
How does backpropagation compute gradients through a deep stack, and why does that make deep nets unstable?
One forward pass caches each layer's activations, then the loss gradient travels backward and every layer multiplies it by its local Jacobian. An early layer's gradient is thus a long product of Jacobians — norms below or above one make it decay or explode exponentially with depth.
Common mistakes
- ✗Confusing backpropagation with numerical finite-difference gradient estimation
- ✗Thinking the layer Jacobians add up instead of multiplying along the path
- ✗Forgetting that the forward pass must cache activations for the backward pass
Follow-up questions
- →How do residual connections change that product of Jacobians?
- →Why does the backward pass cost roughly twice the forward pass?
MiddleTheoryVery commonHow does BatchNorm behave at training versus inference, and how does it differ from LayerNorm?
How does BatchNorm behave at training versus inference, and how does it differ from LayerNorm?
BatchNorm in training normalizes each mini-batch by its own mean/variance and updates running statistics; at inference it uses stored ones, so output is deterministic. LayerNorm normalizes per sample over features, without batch statistics, alike in both phases.
Common mistakes
- ✗Thinking BatchNorm uses the current batch statistics at inference
- ✗Believing LayerNorm depends on the batch dimension
- ✗Forgetting BatchNorm keeps running statistics for inference
Follow-up questions
- →Why does small batch size hurt BatchNorm but not LayerNorm?
- →Why is LayerNorm preferred in Transformers over BatchNorm?
JuniorTheoryCommonWhat is early stopping, which curve do you watch, and what does patience mean?
What is early stopping, which curve do you watch, and what does patience mean?
You watch the validation metric, not the training loss, and stop once it stops improving, restoring the weights saved at the best epoch. Patience is how many epochs without improvement you tolerate, so a noisy dip does not end a run early. It regularizes by capping the capacity the model gets to use.
Common mistakes
- ✗Watching the training loss instead of the validation metric
- ✗Keeping the final-epoch weights rather than restoring the best checkpoint
- ✗Confusing patience with a total epoch budget or a startup delay
Follow-up questions
- →Why must early stopping run against validation rather than test data?
- →How does a patience that is too small interact with a noisy validation curve?
JuniorTheoryCommonHow do an epoch, an iteration and a batch differ, and what changes if you double the batch?
How do an epoch, an iteration and a batch differ, and what changes if you double the batch?
A batch is the samples behind one gradient step, an iteration is that step, and an epoch is one full pass over the training set — so iterations per epoch equal dataset size divided by batch size. Doubling the batch halves iterations and lowers gradient noise, so you scale the learning rate up, with warmup.
Common mistakes
- ✗Swapping the definitions of epoch and iteration
- ✗Multiplying instead of dividing when counting iterations per epoch
- ✗Believing batch size and learning rate can be tuned independently
Follow-up questions
- →Why does a bigger batch reduce the variance of the gradient estimate?
- →When does the linear learning-rate scaling rule stop holding?
JuniorTheoryCommonWhat do loss curves look like when the learning rate is too high versus too low?
What do loss curves look like when the learning rate is too high versus too low?
Too high and the loss spikes, oscillates or diverges to NaN and never settles. Too low and it falls smoothly but far too slowly, flattening above what the model can reach. A range test finds a good value in one run: sweep the rate up exponentially and take the value just before the loss turns upward.
Common mistakes
- ✗Swapping the two symptoms — expecting oscillation from a rate that is too low
- ✗Picking the rate at the loss minimum of a range test rather than just before the turn
- ✗Mistaking a slow but steady descent for a converged model
Follow-up questions
- →Why does the range test pick a value below the loss minimum it observed?
- →How does the best rate change when you switch optimizer from SGD to Adam?
JuniorTheoryCommonWhat ways of regularizing neural networks do you know?
What ways of regularizing neural networks do you know?
The main ones are dropout (randomly zeroing neurons during training) and L2 weight decay. A normalization family — Batch/Layer/Instance/Group Norm — also stabilizes and mildly regularizes training. Data augmentation and early stopping regularize too.
Common mistakes
- ✗Thinking a bigger model always generalizes better
- ✗Believing dropout or weight decay act only at inference
- ✗Not knowing the normalization family beyond BatchNorm
Follow-up questions
- →How exactly does dropout reduce overfitting?
- →Why is BatchNorm considered only a mild regularizer?
JuniorTheoryCommonWhat are vanishing and exploding gradients, and how do they show up in training logs?
What are vanishing and exploding gradients, and how do they show up in training logs?
Vanishing means the gradient shrinks toward zero going back, so early layers barely update and the loss stalls. Exploding means it grows without bound, giving huge weight jumps and a loss that spikes or turns NaN. Deep plain stacks and RNNs without residual connections suffer most.
Common mistakes
- ✗Confusing a vanishing gradient with a loss that has simply converged
- ✗Expecting the symptom in the last layers rather than the earliest ones
- ✗Thinking residual connections aggravate the problem instead of easing it
Follow-up questions
- →Which per-layer statistic would you log to catch this early?
- →Why does the activation function
sigmoidmake vanishing gradients worse?
MiddleTheoryCommonWhen is gradient clipping needed, and how does clipping by norm differ from clipping by value?
When is gradient clipping needed, and how does clipping by norm differ from clipping by value?
You clip when gradients occasionally explode — recurrent nets, transformers, reinforcement learning. Clipping by norm rescales the whole gradient vector once its global norm passes a threshold, so direction is preserved and only step length shrinks. Clipping by value truncates each coordinate on its own, changing the direction.
Common mistakes
- ✗Swapping which variant preserves the gradient direction
- ✗Reaching for clipping to cure vanishing rather than exploding gradients
- ✗Thinking clipping zeroes oversized components instead of bounding them
Follow-up questions
- →What global-norm threshold would you start from, and how would you calibrate it?
- →Why must clipping happen after the backward pass but before the optimizer step?
MiddleTheoryCommonWhy does a very large batch often hurt generalization, and what is the sharp-versus-flat-minima argument?
Why does a very large batch often hurt generalization, and what is the sharp-versus-flat-minima argument?
A bigger batch gives a less noisy gradient, and that noise is part of what regularizes SGD. Without it the optimizer settles into sharp minima, whose loss climbs steeply under small shifts in weights or data, while flat minima tolerate them and transfer better. Scaling the rate with warmup recovers much of it.
Common mistakes
- ✗Thinking a bigger batch adds gradient noise rather than removing it
- ✗Reversing the argument and calling sharp minima the ones that generalize better
- ✗Lowering the learning rate for a large batch instead of scaling it up
Follow-up questions
- →Why is gradient noise described as an implicit regularizer?
- →Which measurable quantity would you use to call a minimum sharp or flat?
MiddleDebuggingCommonTraining loss sits flat and high from epoch one and will not move. How do you diagnose it?
Training loss sits flat and high from epoch one and will not move. How do you diagnose it?
Go cheapest first: try to overfit a single batch — if that fails the bug is in the code, not the data. Then check labels line up with inputs, the loss matches the task, inputs are normalized, and the rate is not wildly off. Last, look for dead ReLUs and parameters the optimizer never got.
Open full question →Common mistakes
- ✗Reading a flat loss as convergence instead of a broken training step
- ✗Adding capacity before verifying the model can overfit a single batch
- ✗Feeding softmax probabilities into a loss that already expects raw logits
Follow-up questions
- →Why is overfitting a single batch the cheapest possible first check?
- →How would you confirm gradients actually reach the earliest layer?
MiddleTheoryCommonHow do cosine, step and one-cycle learning-rate schedules differ, and why do transformers need warmup?
How do cosine, step and one-cycle learning-rate schedules differ, and why do transformers need warmup?
Step drops the rate by a factor at fixed epochs; cosine decays it smoothly toward zero; one-cycle ramps up then back down, often with momentum inverted. Warmup raises the rate from near zero over the first steps because Adam's second moments are still noisy, and a full step would destabilize the residual stack.
Common mistakes
- ✗Swapping which schedule is discrete and which decays smoothly
- ✗Thinking warmup is an infrastructure warm-up rather than an optimizer-stability measure
- ✗Assuming adaptive optimizers make warmup unnecessary
Follow-up questions
- →How long a warmup would you pick, and what does it scale with?
- →Why does cosine decay usually beat a single step drop at the same budget?
MiddleDebuggingCommonThe loss turns NaN in the middle of training. What are the causes, and the fix for each?
The loss turns NaN in the middle of training. What are the causes, and the fix for each?
Exploding gradients — clip by global norm. An fp16 overflow — use a loss scaler or bf16. A hand-written log(0) — use the fused logits loss or add an epsilon. A rate that is too high — lower it or add warmup. NaN already in the batch — assert on inputs. Find the first bad step and log gradient norms.
Open full question →Common mistakes
- ✗Blaming the data and never checking gradient norms or the loss implementation
- ✗Writing log(softmax(x)) by hand instead of using the fused logits loss
- ✗Assuming a GradScaler makes fp16 overflow impossible
Follow-up questions
- →Why does bf16 tolerate overflow better than fp16 at the same bit width?
- →How would you catch the exact step and tensor where the first NaN appears?
MiddleDebuggingCommonTrain loss falls while validation loss rises from epoch three. What do you check, and in what order?
Train loss falls while validation loss rises from epoch three. What do you check, and in what order?
First confirm the gap is real — a validation split big enough to trust, from the same distribution, with no leakage flattering earlier epochs. Then weigh model capacity against dataset size and re-read the rate schedule. Only then add regularization: early stopping first, then dropout and weight decay.
Open full question →Common mistakes
- ✗Reaching for stronger regularization before validating the split and ruling out leakage
- ✗Fitting the scaler on all data, leaking validation statistics into training
- ✗Saving the final-epoch weights when the best model was several epochs earlier
Follow-up questions
- →Why does a 5% validation split make an early divergence hard to trust?
- →Which regularizer would you reach for first, and why that one?
MiddleTheoryCommonWhy can weights not all start at zero, and what does Xavier and He initialization each fix?
Why can weights not all start at zero, and what does Xavier and He initialization each fix?
All-zero weights make every unit in a layer compute the same output and get the same gradient, so they stay identical and symmetry is never broken. Xavier scales initial variance by fan-in and fan-out to hold signal variance steady through tanh and sigmoid; He doubles it for ReLU, which zeroes half its inputs.
Common mistakes
- ✗Believing bias terms alone are enough to break symmetry between units
- ✗Swapping which initializer targets ReLU versus tanh and sigmoid
- ✗Thinking He halves the variance rather than doubling it
Follow-up questions
- →Why does initializing too large a variance mimic exploding gradients?
- →Which initialization suits a residual branch whose output is added back?
SeniorTheoryCommonHow does dropout behave at inference versus training, and how is the activation scale kept consistent?
How does dropout behave at inference versus training, and how is the activation scale kept consistent?
At inference NO neurons are dropped — the full network runs. To match the training activation magnitude, standard dropout multiplies activations by (1−p) at inference (p = drop probability). The common alternative, inverted dropout, scales kept activations by 1/(1−p) DURING training and does nothing at inference.
Common mistakes
- ✗Thinking neurons are still dropped at inference
- ✗Swapping which phase gets the (1−p) versus 1/(1−p) scaling
- ✗Forgetting that scaling exists to match expected activation magnitude
Follow-up questions
- →Why does inverted dropout move the scaling into the training phase?
- →What goes wrong if you forget to rescale entirely?
JuniorTheoryOccasionalYou want batch_size = 2048 but memory only fits 32. How do you train as if the batch were 2048?
You want batch_size = 2048 but memory only fits 32. How do you train as if the batch were 2048?
Use gradient accumulation. Run forward + loss.backward() on each micro-batch of 32, letting gradients sum in the .grad buffers, and call optimizer.step() + optimizer.zero_grad() only once every 2048/32 = 64 micro-batches. With mean-reduced losses, scale each loss by 1/64.
Common mistakes
- ✗Calling zero_grad after every micro-batch, wiping the accumulation
- ✗Forgetting to scale the loss by 1/accum_steps for mean-reduced losses
- ✗Thinking a learning-rate bump replaces real accumulation
Follow-up questions
- →Why must zero_grad be called only after the accumulation window?
- →How does BatchNorm complicate gradient accumulation?
MiddleDesignOccasionalFraudulent sellers create many accounts posting near-duplicate listings to flood search results. For a given account you can find technically-linked accounts (e.g. those that logged in from the same IP), forming a noisy neighborhood. Propose a neural-network architecture that classifies an account from its neighborhood, and explain how it copes with a variable number of neighbors in arbitrary order.
Fraudulent sellers create many accounts posting near-duplicate listings to flood search results. For a given account you can find technically-linked accounts (e.g. those that logged in from the same IP), forming a noisy neighborhood. Propose a neural-network architecture that classifies an account from its neighborhood, and explain how it copes with a variable number of neighbors in arbitrary order.
Model the neighborhood as an unordered SET (or graph) and use a permutation-invariant architecture: Deep Sets, attention pooling, or a Graph Attention Network (GAT). Embed each neighbor, then aggregate symmetrically (sum/mean or attention) — making the output order-invariant and accepting any neighbor count.
Common mistakes
- ✗Using order-sensitive models (RNN, fixed concatenation) for an unordered set
- ✗Assuming a fixed neighbor count instead of variable cardinality
- ✗Relying on the single most-similar neighbor and missing collective signals
Follow-up questions
- →Which symmetric aggregation makes the network order-invariant, and why?
- →How does attention pooling weigh more suspicious neighbors higher?
SeniorTheoryOccasionalWhat is double descent, and what does it break in the classical bias-variance U-curve?
What is double descent, and what does it break in the classical bias-variance U-curve?
As capacity grows, test error follows the classical U up to the interpolation threshold, where the model just barely fits the training set and error peaks. Past it error falls again: among the many zero-training-error solutions the optimizer picks smoother, lower-norm ones. The U describes only the underparameterized regime.
Common mistakes
- ✗Reading the curve as training error rather than test error against capacity
- ✗Placing the error peak somewhere other than the interpolation threshold
- ✗Assuming all zero-training-error solutions are equally likely to be selected
Follow-up questions
- →What implicit bias makes the optimizer prefer a lower-norm interpolating solution?
- →Where does epoch-wise double descent appear, and how does it differ from the capacity-wise form?
SeniorPerformanceOccasionalTraining OOMs at batch 32 — what occupies GPU memory, and how do you rank the levers that free it?
Training OOMs at batch 32 — what occupies GPU memory, and how do you rank the levers that free it?
Weights, optimizer state (Adam holds two moments), gradients and the activations cached for backward dominate; activations scale with batch times depth. Rank levers by cost — mixed precision, then gradient accumulation, activation checkpointing, ZeRO sharding, CPU offload.
Common mistakes
- ✗Counting only the weights and forgetting optimizer state and cached activations
- ✗Treating activation checkpointing as free rather than trading compute for memory
- ✗Believing a smaller micro-batch shrinks the optimizer-state footprint
Follow-up questions
- →Why does Adam need roughly three times the state a plain SGD run needs?
- →What does activation checkpointing cost in throughput, and when is it worth it?