Skip to content
Tech Interview Prep
Technical interview guide

Neural Network Fundamentals

Forward pass, backpropagation, and the activation functions that make deep networks work.

Minutes to read
3
Practice MCQs
25
Interview Q&A
25
Edition
v4
Editorial status
Reviewed

Scope: Google ML Crash Course neural-network guidance, TensorFlow Keras guides, and PyTorch stable reproducibility guidance accessed 2026-08-31..

Overview

Curated: · Written: · Reviewed:

Neural Network Fundamentals

In one line

A feed-forward network stacks dense layers, each computing z = Wx + b followed by an elementwise nonlinearity, and trains by backpropagating the loss gradient through the chain rule. Reach for it when the signal is high-dimensional or you need a differentiable component, and you have enough labelled data to beat a linear or tree baseline.

Key definitions

  • Pre-activation: z = Wx + b, the value fed into the activation function.
  • Logit: the raw, unnormalised output that softmax cross-entropy consumes directly.
  • Dead ReLU: a unit whose pre-activation stays negative across the data, so it passes zero gradient upstream.
  • Saturation: sigmoid or tanh outputs near their limits, where the local derivative is near zero.
  • Gradient accumulation along paths: a parameter used on several paths receives the sum of every contribution.
  • Running statistics: the BatchNorm mean and variance estimates used at inference.

Formulas and complexity

z=Wx+b,W∈Rout×inz = Wx + b, \quad W \in \mathbb{R}^{\text{out} \times \text{in}} He init: Var⁡(W)=2ninXavier init: Var⁡(W)=2nin+nout\text{He init: } \operatorname{Var}(W) = \frac{2}{n_{\text{in}}} \qquad \text{Xavier init: } \operatorname{Var}(W) = \frac{2}{n_{\text{in}} + n_{\text{out}}} softmax⁡(z)k=ezk−max⁡jzj∑jezj−max⁡jzj\operatorname{softmax}(z)_k = \frac{e^{z_k - \max_j z_j}}{\sum_j e^{z_j - \max_j z_j}}

A dense layer costs O(B x in x out) multiply-adds per batch. Adam keeps two moments per parameter, so a training checkpoint is roughly 3x the model size in fp32.

How it works

  • Each dense layer computes z = Wx + b on the batch, then applies the activation elementwise.
  • The loss is computed from the final output: logits for classification, the linear output for regression.
  • Backprop walks the graph from the loss, applying the chain rule at each node. Shared parameters receive the sum over paths.
  • .detach() or requires_grad=False cuts the graph. Nothing upstream of the cut receives gradient.
input x: B x d Dense + ReLU: z1 = W1 x + b1 Dense + ReLU: z2 = W2 h1 + b2 Output logits Loss: softmax cross-entropy

When to use and when not to

SituationDense networkPrefer
High-dimensional dense signal (embeddings, images, text features), many labelsGood fitn/a
Tabular data, modest row countUsually losesGradient-boosted trees
Per-feature interpretability or monotonicity requiredWeakLinear model
Calibrated probabilities from small dataLess reliableLogistic regression
Tiny latency or memory budgetHeavyLinear model or lookup
Bit-exact reproducibility across machinesHardSimpler model

Traps interviewers probe

  1. Softmax then log. Applying softmax and then -log(p) gives inf at extreme logits (logits [1000, 0, 0] give inf naively, 1000.0 with fused cross-entropy). Fix: pass logits to the fused loss.
  2. Stacking linear layers without activations. Stacked affine maps collapse to one affine map, so depth adds no capacity. Fix: put a nonlinearity between layers.
  3. Xavier with ReLU. ReLU zeroes half the pre-activations and halves the variance. Fix: He initialization.
  4. Dropout or batch statistics left in training mode at inference. Fix: call model.eval(). Dropout becomes identity and BatchNorm uses running statistics.
  5. Treating gradient clipping as the fix for exploding gradients. Clipping caps the update size but hides the cause. Fix: check learning rate, initialization, normalization and residual paths, then say so explicitly.

Interview tips

Open with the mechanism: a dense network is a stack of learned linear projections, each followed by a nonlinearity, and the nonlinearity is what gives depth its capacity.

Follow-ups to expect:

  • Shapes for input (B, 784) into a 256-unit layer: W is (256, 784), b is (256,), output is (B, 256).
  • Which initialization with ReLU, and why: He, because ReLU halves the variance per unit.
  • What happens at a detached branch: its outputs are constants and nothing upstream receives gradient.
  • Offline metric improved, A/B test did not: check distribution shift, leakage in the offline split, and metric-proxy mismatch, in that order.
  • Loss plateaus early: compare per-layer gradient norms with depth, and check for saturation or dead units.

30-second outline:

  1. Define the layer: z = Wx + b, then a nonlinearity.
  2. Why the nonlinearity matters: without it the stack is one affine map.
  3. Loss pairing: logits into the fused cross-entropy, or a regression loss matched to the error cost.
  4. Training: backprop through the chain rule, gradients summed over shared paths.
  5. One trap to name (softmax then log, or Xavier with ReLU).
  6. When not to use it: tabular data with modest rows, or a need for calibration or interpretability.

Feedback on this overview

Log in free to save your progress and keep bookmarks and notes for a quick revision before your interview.