Skip to content

Deep Learning interview questions

Neural networks from backpropagation to attention, and the tricks that make them trainable.

49 questions in this category.

These cards group around what you get asked to explain at a whiteboard: activation functions and why a network is a linear model without them, gradient descent and the learning rate that makes or breaks it, dropout and batch normalization, and the architectures that stack the pieces into something useful: CNNs, LSTMs and GRUs, GANs, autoencoders, Transformers and the self-attention inside them. Beyond architecture, there are training ideas such as contrastive learning and knowledge distillation.

Start with these

  1. Why do we need activation functions?
  2. What is ReLU? How is it better than sigmoid?
  3. What is the learning rate?
  4. How does dropout regularization work in deep learning?
  5. What’s pooling in CNN? Why do we need it?

Training with gradient descent11 questions

How a network learns: what gradient descent minimizes, its batch, mini-batch and stochastic versions, adaptive optimizers like AdaGrad, epochs and batches, why the learning rate is the first setting to tune, and why the weights can't all start at zero. The popular frameworks are here too.

What is the difference between batch, mini-batch and stochastic gradient descent?
How many examples each update uses: batch gradient descent uses the whole training set, stochastic gradient descent (SGD) one example, and mini-batch gradient descent a small batch, typically 32 to 512.
What is an epoch?
A full training pass over the entire dataset such that each example has been seen once.
What is a batch?
The set of training examples processed together in one forward and one backward pass, producing one weight update. The number of examples in it is the batch size.
What is AdaGrad?
A sophisticated gradient descent algorithm that rescales the gradients of each parameter, effectively giving each parameter an independent learning rate.
What is the learning rate?
The step size of gradient descent: each update moves the weights by the learning rate times the gradient. Too high and the loss oscillates or diverges; too low and training crawls.
What if we set all the weights of a neural network to 0?
The network can't learn useful features: every unit in a layer computes the same output and gets the same gradient, so the symmetry never breaks. With tanh or ReLU the weights don't move at all; with sigmoid they move in lockstep. Use small random weights instead.
Initializing a neural network’s weights with zero is our best bet to allow the network to converge.
False: with zero weights every unit in a layer computes the same thing and receives the same gradient, so the symmetry never breaks and the layer behaves like a single neuron. Use small random values scaled to the layer's size: He (variance 2/fan_in) for ReLU, Xavier (variance 2/(fan_in + fan_out)) for tanh. Biases can start at zero.
Name three different deep learning frameworks.
PyTorch, TensorFlow and JAX. Keras is a popular high-level API that runs on top of them; older frameworks include Caffe and Theano.

Activation functions9 questions

Why a network needs nonlinear activations at all, why ReLU replaced sigmoid in hidden layers, and the output ranges of sigmoid, tanh and softmax. Several cards are true-or-false traps that swap what one function returns for another's.

Why do we need activation functions?
Without a nonlinear activation, stacked layers collapse into one linear map: W₂(W₁x + b₁) + b₂ is just another linear function of x. Activation functions add the nonlinearity that lets a neural network learn complex functions, such as XOR, that no linear model can represent.
In neural networks, an activation function’s most essential role is to decide whether a unit or neuron should fire.
False. The fire-or-not idea comes from early step-function neurons. An activation function's essential role is to add nonlinearity, without which stacked layers collapse into one linear map.
Which activation function follows these rules: If input is negative or zero, output is 0 and if input is positive, output is equal to input.
ReLU, the rectified linear unit, max(0, x). It is cheap and its gradient is exactly 1 on the positive side, so it does not saturate as sigmoid and tanh do, which is much of why deep stacks became trainable. Its failure mode is dead units stuck at zero.
What is ReLU? How is it better than sigmoid?
ReLU, max(0, x), zeroes negative inputs and passes positive ones through. Unlike sigmoid it doesn't saturate for positive inputs, where its gradient is 1, so it greatly reduces vanishing gradients in deep networks, and it is cheaper to compute.
What are the problems with sigmoid as an activation function?
It saturates: for large positive or negative inputs its gradient is nearly zero, which causes vanishing gradients in deep networks. Its outputs are also always positive rather than zero-centered. Tanh fixes the centering but still saturates, which is why ReLU took over.
Sigmoid squishes values to be between?
0 and 1, which is what makes it the right output layer for a binary probability. Inside a deep network it is a poor choice: gradients vanish once inputs saturate at either tail, and its output is not zero-centred, so ReLU-family activations replaced it in hidden layers.
Explain what a softmax function does.
Provides probabilities for each possible class in a multi-class classification model. The probabilities add up to exactly 1.0

Dropout, normalization and capacity6 questions

How capacity grows with layers and shrinks with dropout, what batch normalization is and isn't, and the universal approximation theorem, which says one hidden layer is enough in principle.

How does dropout regularization work in deep learning?
During training, each unit in a layer is set to zero independently with probability p on every forward pass, so each gradient step trains a different random sub-network. At inference no units are dropped.
Batch Normalization is an efficient backpropagation technique that allows neural networks to learn.
False — it is a normalization layer, not a backpropagation technique. It standardises each activation across the mini-batch, then rescales with learned parameters, which smooths optimisation and allows higher learning rates. Batch statistics also add noise, so it regularises mildly.
A neural network with a single layer is capable of approximating any function.
True with conditions: by the universal approximation theorem, one hidden layer with enough units and a non-polynomial activation can approximate any continuous function on a closed, bounded domain. With no hidden layer, a network only draws linear boundaries and can't even fit XOR.

CNNs, RNNs, GANs and autoencoders9 questions

The architectures that came before Transformers: convolution and pooling for images, and why a CNN is only roughly translation invariant; LSTMs and GRUs and the gates that tell them apart; the generator and discriminator of a GAN; and autoencoders, which learn by reconstructing their own input.

What are the two actors in a convolution operation?
Convolutional filter and a slice of an input matrix.
What’s pooling in CNN? Why do we need it?
Pooling downsamples each feature map by summarizing small windows, usually with the max or the average. It reduces spatial size and computation, lets deeper layers cover a larger part of the input, and makes features somewhat robust to small shifts. It has no learned weights.
Convolutional neural networks are translation invariant.
False as stated: convolution layers are translation equivariant, and pooling makes a CNN only approximately invariant to small shifts.
What is an LSTM?
A Long Short-Term Memory network: a recurrent neural network with a cell state and three gates (forget, input and output) that decide what to erase, write and expose at each step, which lets it learn dependencies across long sequences.
What is a GRU?
A Gated Recurrent Unit: a recurrent neural network cell with two gates, reset and update, and no separate cell state. It is a simpler alternative to the LSTM, with about 25% fewer parameters, and it usually performs about as well.
Which are the two components of a Generative Adversarial Network?
A generator that turns noise into samples and a discriminator that judges them real or fake, trained against each other in a minimax game. The tension is the point and also the difficulty: unstable training and mode collapse, where the generator serves one convincing output.
What is the function of the discriminator in a GAN?
Determine whether examples are real or fake.
What is an autoencoder?
A neural network trained to reproduce its input: an encoder compresses it into a small code and a decoder rebuilds it. The input is its own target, so it needs no labels and counts as unsupervised, or self-supervised, learning.

Transformers, attention and decoding5 questions

The Transformer one part at a time: self-attention, multi-head attention, positional encoding and the residual connections that force every sub-layer to the same width, plus beam search for decoding. The generative AI cards pick up from here with large language models.

What is self-attention?
A layer in which each token builds its new representation as a weighted average of every token's value vector, with the weights set by how well its query matches their keys: softmax(QKᵀ / √dₖ)V. Each token can draw on any other token directly, whatever the distance between them.
What is multi-head attention?
Running several attention operations in parallel, each with its own learned projections of the queries, keys and values into a smaller subspace, then concatenating the results and projecting them back. Different heads can track different relationships, such as nearby words, syntax or what a pronoun refers to, within the same layer.
What is positional encoding in transformers?
Information about each token's position, added to or mixed into its representation, because self-attention on its own treats the input as an unordered set. The original Transformer added fixed sine and cosine waves of different frequencies; most current LLMs use rotary position embeddings (RoPE) instead.
What is beam search?
A decoding method that keeps the k most probable partial sequences, the beam, at each step instead of only the single best next token. It finds higher-probability outputs than greedy decoding, which can commit early to a token that leads nowhere, at roughly k times the cost.

Vision metrics and training methods4 questions

Ideas from computer vision and representation learning: intersection over union for scoring predicted boxes, focal loss for detectors swamped by easy background examples, contrastive learning for learning embeddings, often without labels, and knowledge distillation for shrinking a model.

What is intersection over union (IoU)?
A measure of overlap between a predicted region and the ground truth: the area of their intersection divided by the area of their union. It runs from 0 for no overlap to 1 for a perfect match and is the standard score for detection boxes and segmentation masks.
What is focal loss?
A version of cross-entropy that down-weights easy examples: FL = −(1 − p_t)^γ log(p_t), where p_t is the probability given to the true class. With γ > 0, well-classified examples contribute little, so training concentrates on the hard ones; γ = 0 gives back cross-entropy.
What is contrastive learning?
Learning representations by pulling the embeddings of related pairs together and pushing unrelated ones apart, for example two augmented crops of the same photo, or an image and its caption. It needs no class labels, only a way to say which examples belong together.
What is knowledge distillation?
Training a smaller student model to imitate a larger teacher by matching the teacher's full output probabilities, not just the hard labels. The soft probabilities carry extra information, such as which wrong classes are close to the right one, so the student learns more from each example.

Rapid-fire basics5 questions

Quick true-or-false checks on the vocabulary around deep learning: categorical features and one-hot encoding, multi-class labels, and precision and recall.

The type of problem where you need to classify the input into a single class is called multi class classification.
True, when there are three or more classes: each input gets exactly one label. With two classes it's binary classification; when an input can carry several labels at once, it's multi-label classification.

Created by santiviquez

About · Quizzes · History of AI · To suggest new questions or report an error send me a dm.