Deep learning interview questions and answers

Deep learning interview questions test whether you understand how a neural network learns, not only which layers to stack. Expect backpropagation and the chain rule, activation functions, vanishing and exploding gradients, batch and layer normalization, optimizers such as Adam, CNNs, RNNs versus transformers, attention, dropout, transfer learning, and how to debug a model whose loss will not go down. Strong answers explain why each piece exists and what breaks without it.

By Published 7 min read

Where deep learning questions come up

Deep learning is tested for ML engineers, research engineers, computer vision and speech roles, applied scientists, and many AI engineering loops. Research-leaning interviews go into derivations and papers. Product and engineering interviews care more about training stability, compute budgets and shipping a model that works on real data. Most loops assume you already know classical ML, which has its own page in machine learning interview questions.

  1. Theory screenBackprop, activations, normalization and optimizers, often with a small derivation on a whiteboard or shared doc.
  2. CodingWrite a layer, attention or a training loop in PyTorch or NumPy, or find the bug in a short training script.
  3. Architecture discussionPick and justify a model for an image, sequence or text problem and talk through data, loss and evaluation.
  4. Debugging and scaleWhy the loss is NaN, why validation got worse, how to fit a bigger model on the same GPU.

Neural network fundamentals

Fundamentals asked of freshers and experienced candidates alike
QuestionWhat it testsWhat a strong answer shows
Explain backpropagation.Core mechanicsThe forward pass computes activations and the loss. The backward pass applies the chain rule from the loss back through each layer, reusing the stored activations, to get the gradient of the loss with respect to every weight. An optimizer then updates the weights.
Why do networks need nonlinear activations?ExpressivenessWithout them, any stack of linear layers collapses to a single linear map, so depth adds nothing.
ReLU versus sigmoid versus tanh?ActivationsSigmoid and tanh saturate, so their gradients shrink toward zero at the extremes. ReLU does not saturate for positive inputs and is cheap, but units can die if they only ever see negative inputs. GELU and SiLU are smooth variants common in transformers.
What causes vanishing and exploding gradients?Gradient flowBackprop multiplies many per-layer factors. If they are mostly below one, gradients shrink toward zero in early layers; if above one, they blow up. Saturating activations and poor initialization make it worse.
How do you fix vanishing or exploding gradients?RemediesNon-saturating activations, careful initialization (Xavier or He), normalization layers, residual connections, gated recurrent units for sequences, and gradient clipping for explosions.
Why does weight initialization matter?InitializationWeights that are too large or too small push activations into saturation or toward zero layer after layer. Xavier and He initialization scale the variance by layer width so signals keep a stable size. All-zero weights make every unit in a layer learn the same thing.
Why softmax with cross-entropy for classification?Loss designSoftmax turns logits into probabilities and cross-entropy penalizes low probability on the true class. Together their gradient is simply the predicted probability minus the one-hot target, which is stable and easy to optimize.
What is the difference between an epoch, a batch and an iteration?VocabularyAn epoch is one pass over the training set, a batch is the subset used for one gradient step, and an iteration is one such step.
Why use mini-batches rather than the full dataset?OptimizationFull-batch gradients are expensive and often do not fit in memory. Mini-batches give noisy but cheap estimates, use hardware efficiently, and the noise can help escape poor regions.
Fundamentals asked of freshers and experienced candidates alike. Scroll sideways on a small screen.

Training, optimization and regularization questions

  • SGD with momentum versus Adam? Momentum smooths updates by averaging past gradients. Adam also scales each parameter's step by a running estimate of its gradient size, which makes it forgiving of the learning rate. Well-tuned SGD can generalize better on some vision tasks; Adam and AdamW are the usual default for transformers.
  • What is the difference between Adam with L2 and AdamW? In Adam, an L2 term added to the loss gets rescaled by the adaptive step, so it does not behave like true weight decay. AdamW applies the decay directly to the weights, separately from the gradient update.
  • Why use a learning rate schedule and warmup? Large steps early can destabilize training, especially with normalization and attention, so warmup ramps up. Decaying the rate later (step, cosine or linear) lets the model settle into a better minimum.
  • Batch normalization versus layer normalization? Batch norm normalizes each feature across the batch and behaves differently in training and inference because it keeps running statistics. Layer norm normalizes across features within each example, does not depend on batch size, and is the standard in transformers.
  • What does dropout do, and why is it off at inference? During training it zeroes random units and scales the rest, so the network cannot rely on any single unit. At inference every unit is used, which is why forgetting model.eval() changes your results.
  • What other regularizers do deep networks use? Weight decay, data augmentation, early stopping, label smoothing and, in effect, smaller batch sizes. More data usually beats all of them.
  • What is gradient clipping and when do you need it? Rescaling gradients when their norm passes a limit. It is standard for recurrent networks and large transformers, where single bad batches can cause spikes.
  • What is mixed-precision training? Running most math in 16-bit formats to save memory and time, while keeping a 32-bit copy of the weights. With float16 a loss scaler prevents small gradients from underflowing; bfloat16 has float32's range and usually does not need one.
import torch
from torch import nn

torch.manual_seed(0)
x = torch.randn(32, 20)                 # one small batch
y = torch.randint(0, 3, (32,))

model = nn.Sequential(nn.Linear(20, 64), nn.ReLU(), nn.Linear(64, 3))
opt = torch.optim.Adam(model.parameters(), lr=1e-2)
loss_fn = nn.CrossEntropyLoss()         # expects raw logits, applies log-softmax itself

model.train()
for step in range(300):
    opt.zero_grad()                     # gradients accumulate unless cleared
    loss = loss_fn(model(x), y)
    loss.backward()
    opt.step()

print(loss.item() < 0.05)               # a healthy setup memorizes one batch
The first debugging step for any new model: it should be able to memorize one small batch. If it cannot, the bug is in the code, not the data.

CNN questions

Convolutional network questions for vision and general roles
QuestionWhat it testsWhat a strong answer shows
Why use convolutions instead of fully connected layers for images?Inductive biasLocal connectivity and shared weights: the same small filter slides over the image, so the model learns local patterns once, uses far fewer parameters, and responds to a pattern wherever it appears.
How many parameters does a 3x3 conv layer with 64 input and 128 output channels have?Arithmetic3 x 3 x 64 x 128 weights plus 128 biases, so 73,728 + 128 = 73,856. The image size does not change the count.
What is the receptive field and how do you grow it?ArchitectureThe region of the input that affects one output unit. Stacking layers, striding, pooling and dilated convolutions all enlarge it.
What do pooling and stride do?DownsamplingThey reduce spatial size, which saves compute and grows the receptive field. Many modern designs use strided convolutions instead of max pooling.
Why did residual connections make very deep networks trainable?ResNetsThe block learns a change added to its input, so gradients have a direct path backwards through the identity. Without it, simply adding layers made training error worse.
What is a 1x1 convolution for?Channel mixingIt mixes information across channels at each position and can cheaply shrink or grow the channel count, as in bottleneck blocks.
Convolutional network questions for vision and general roles. Scroll sideways on a small screen.

RNNs, transformers and attention

Sequence questions usually start with why transformers replaced recurrent networks and end with writing attention. Tokenization, embeddings and large language model questions continue on NLP interview questions.

import math
import torch
import torch.nn.functional as F

def attention(q, k, v, causal=False):
    # q, k, v: (batch, seq_len, d)
    d = q.size(-1)
    scores = q @ k.transpose(-2, -1) / math.sqrt(d)      # (batch, seq, seq)
    if causal:
        seq = q.size(-2)
        mask = torch.triu(torch.ones(seq, seq, dtype=torch.bool), diagonal=1)
        scores = scores.masked_fill(mask, float("-inf"))  # hide future positions
    weights = scores.softmax(dim=-1)                      # each row sums to 1
    return weights @ v

torch.manual_seed(0)
q, k, v = (torch.randn(2, 5, 16) for _ in range(3))
ours = attention(q, k, v, causal=True)
ref = F.scaled_dot_product_attention(q, k, v, is_causal=True)
print(torch.allclose(ours, ref, atol=1e-6))   # True
Scaled dot-product attention with a causal mask, checked against PyTorch's built-in function.
Sequence model questions
QuestionWhat it testsWhat a strong answer shows
Why did LSTMs improve on plain RNNs?GatingA cell state with input, forget and output gates lets information and gradients pass across many steps, which eases vanishing gradients. GRUs do something similar with fewer gates.
Why did transformers replace RNNs for most sequence tasks?ParallelismSelf-attention connects any two positions in one step and processes all positions in parallel during training, while an RNN must step through the sequence in order.
Why divide attention scores by the square root of the dimension?ScalingDot products of random vectors grow with dimension. Large scores push softmax into a nearly one-hot region with tiny gradients; scaling keeps them in a trainable range.
What does multi-head attention add?RepresentationSeveral smaller attention heads with their own projections can attend to different relationships at once; their outputs are concatenated and projected back.
Why do transformers need positional information?OrderAttention by itself ignores order. Sinusoidal or learned position embeddings, or relative schemes such as rotary embeddings, tell the model where each token sits.
What is the cost of self-attention in sequence length?ComplexityQuadratic in time and memory for the full attention matrix, which is why long contexts need memory-efficient kernels or sparse and linear variants.
Encoder-only, decoder-only or encoder-decoder?ArchitecturesEncoders with bidirectional attention suit classification and embeddings, decoders with causal masks suit generation, and encoder-decoder models suit input-to-output tasks such as translation.
Sequence model questions. Scroll sideways on a small screen.

Transfer learning and debugging questions

Senior and scenario questions
ScenarioWhat it testsWhat a strong answer shows
You have 2,000 labeled images. How do you build a classifier?Transfer learningStart from a pretrained backbone, replace the head, train the head first, then unfreeze later layers with a lower learning rate. Use augmentation and a careful validation split.
The loss becomes NaN after a few hundred steps.StabilityA learning rate too high, a log or division of zero, exploding gradients or float16 overflow. Lower the rate, add clipping, check inputs for NaNs and inspect the batch where it happened.
The loss starts and stays near the value of random guessing.Sanity checksFor balanced classes, cross-entropy at the start should be close to log of the class count. If it never drops, check labels align with inputs, gradients reach the weights, the optimizer holds the right parameters and you are not detaching tensors.
Validation accuracy drops while training accuracy keeps rising.OverfittingStop earlier, add augmentation or weight decay, reduce capacity, or get more data. Also confirm the validation set matches the real distribution.
The model works in the notebook but is worse after export.Train and serve gapDifferent preprocessing at inference, dropout or batch norm left in training mode, or a change in input resolution or normalization constants.
The model does not fit in GPU memory.MemorySmaller batches with gradient accumulation, mixed precision, activation checkpointing, and sharding the model or optimizer state across devices.
Senior and scenario questions. Scroll sideways on a small screen.

Fictional example

"Walk me through debugging a model that will not train"
Interviewer
A colleague's image classifier has been training for an hour and the loss has barely moved. Where do you start?
Candidate
I would make the problem small. First I would print a batch and its labels to confirm they match, and check the starting loss is near log of the number of classes. Then I would try to overfit a single batch with the same code. If it cannot, the bug is mechanical: a missing zero_grad, a loss that expects logits but gets softmax outputs, a frozen layer, or an optimizer built before the model was moved or changed. If it can, I would look at the learning rate with a short range test, then at the data pipeline, for example whether augmentation is so heavy the images are unrecognizable. I would log gradient norms per layer to see whether anything reaches the early layers at all.

A two-week deep learning practice plan

  • Days 1 to 3: derive backprop for a two-layer network by hand, then write it in NumPy and check your gradients against finite differences.
  • Days 4 to 6: train a small CNN in PyTorch, then break it on purpose: remove normalization, set a huge learning rate, forget eval mode. Note each symptom.
  • Days 7 and 8: write attention and a single transformer block from scratch and compare with the library version.
  • Days 9 and 10: fine-tune a pretrained model on a small dataset and explain each choice of what to freeze.
  • Days 11 to 14: practice spoken one-minute answers on optimizers, normalization and the debugging checklist, then one mock design discussion.

For the surrounding loop, see AI engineer interview questions for building products on large models and data scientist interview questions for statistics and experimentation.

Explaining a derivation or a debugging plan out loud is a skill of its own, and it is hard to judge from memory. Natively, an AI interview assistant for Mac and Windows, transcribes your mock deep learning rounds on your computer so you can reread where an explanation wandered. While you practice it can read a training script, an error trace or a loss curve from a screenshot and suggest what to look at, and with Pro or the free trial it can use the résumé and job description you add. Afterwards the transcript and notes are there to review.

Questions people ask

What deep learning questions are asked in interviews?

Backpropagation, activation functions, vanishing and exploding gradients, initialization, batch versus layer normalization, SGD versus Adam, dropout, CNN basics, RNNs versus transformers, attention, transfer learning and how to debug a model that will not train.

How do I explain backpropagation in an interview?

Describe the forward pass that computes the loss, then the backward pass that applies the chain rule layer by layer from the loss to every weight, reusing stored activations, before the optimizer updates the weights.

Why is attention scaled by the square root of the dimension?

Dot products grow with vector dimension, and large scores saturate the softmax so gradients become tiny. Dividing by the square root of the key dimension keeps scores in a range where training works well.

Do deep learning interviews include coding?

Often. Typical tasks are writing a training loop or attention in PyTorch, implementing a layer in NumPy, or finding the bug in a short training script.

Where to go next

Practice with the same assistant you would use on a call: it listens, transcribes and suggests answers from your own resume and the job description.

Facts on this page were last checked on . Product details come from the Natively app itself; if something here is out of date, tell us at hello@heynatively.com.

Keep reading

Put it on your own machine.

A live-conversation assistant that runs locally. Your conversations stay on your machine.

macOS 12+ · Windows 10/11

© 2026 Natively AI Private Limited

Source-available under the Natively Personal Use Source License v1.0 · IP geolocation by DB-IP