Test 3. Deep Learning
Describe the computational model of an artificial neuron. Write its mathematical equation. Explain the roles of the input features, weights, bias, and how the neuron’s output is produced.
An artificial neuron computes a weighted sum of inputs plus a bias, then applies an activation:
- Inputs
: feature values. - Weights
: scale each input’s contribution. - Bias
: allows shifting the activation threshold. - Activation
: nonlinearly transforms into the neuron’s output .
Explain the forward pass in a feedforward neural network. How are activations computed layer by layer? Illustrate with a two‑layer (one hidden, one output) network.
In a forward pass, each layer’s outputs become the next layer’s inputs:
- Hidden layer:
- Output layer:
: weights and biases of layer . : activation functions (e.g., ReLU in hidden, softmax in output).
Compare common activation functions—sigmoid, tanh, ReLU, and Leaky ReLU. For each, give its formula, output range, and discuss advantages and drawbacks. When might you choose one over another?
- Sigmoid:
, range . - Pros: smooth, interpretable as probability.
- Cons: vanishing gradients for
.
- Tanh:
, range . - Pros: zero‑centered.
- Cons: still suffers vanishing gradients.
- ReLU:
, range . - Pros: sparse activation, mitigates vanishing gradient.
- Cons: “dying ReLU” (units stuck at zero).
- Leaky ReLU:
with small , range . - Pros: alleviates dying ReLU.
- Cons: adds a small negative slope hyperparameter.
- Choice: ReLU/Leaky ReLU in deep nets for faster training; sigmoid/tanh in output layers for bounded outputs.
Describe gradient descent optimization. Derive the weight‑update rule for a parameter
- Update rule:
where is the learning rate. - Variants:
- Batch GD: use all
examples to compute gradient (stable but slow). - Stochastic GD: update per example (noisy but fast).
- Mini‑batch GD: update per batch of size
(balance of noise and speed).
- Batch GD: use all
- Hyperparameters:
- Learning rate
- Batch size
- Momentum, decay schedules
- Learning rate
Explain the backpropagation algorithm. How does it use the chain rule to compute gradients for all weights in a multilayer network? Outline the main steps.
- Forward pass: compute and cache activations
and pre‑activations . - Output error:
. - Backpropagate: for
, - Gradient:
. - Update weights via gradient descent.
Define the vanishing gradient problem. Why does it occur in deep networks? What strategies (architectural or algorithmic) help mitigate it?
- Vanishing gradients: gradients shrink exponentially as they backpropagate through many layers, slowing or stalling learning in early layers.
- Causes:
- Activation derivatives
(e.g. sigmoid, tanh). - Poor weight initialization.
- Activation derivatives
- Mitigations:
- Use ReLU or its variants.
- He or Xavier initialization.
- Batch normalization.
- Residual connections (ResNets).
Outline the typical training loop for a neural network. What are the key steps performed each epoch and per batch? How do you integrate data loading, forward pass, loss computation, backward pass, and parameter updates?
For each epoch:
- Shuffle training data.
- For each batch:
- Load inputs
and labels . - Forward pass: compute
. - Compute loss:
. - Backward pass: compute gradients
. - Update parameters
.
- Load inputs
- Validation: evaluate on hold‑out set.
- Logging: track metrics, adjust learning rate or early stop.
Describe the core components of a convolutional neural network (CNN). What is a convolutional layer? Explain the convolution operation, receptive field, pooling layers, and how CNNs exploit spatial structure.
- Convolutional layer: applies learnable filters
over input feature maps via sliding-window dot products: - Receptive field: region of input influencing a given output unit.
- Pooling layer: down‑samples feature maps (e.g. max or average) to reduce spatial size and introduce invariance.
- Spatial exploitation: weight sharing (same filter across locations) and local connectivity capture translational features efficiently.