Deep Learning Lecture 2
- 27Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
What is the primary reason for using batches of examples in neural network training?
What is the primary reason for using batches of examples in neural network training?
27 questions
- 1
What is the primary reason for using batches of examples in neural network training?
- A
To make the cost function more convex
- B
To reduce overfitting by averaging gradients
- C
To enable vectorized computation for parallel processing on GPUs
- D
To decrease the number of parameters needing updates
Correct answer
CTo enable vectorized computation for parallel processing on GPUs
Explanation
Batches allow vectorization, leveraging GPU parallelism for faster computation. The lecture states: 'We want to use what our GPU can do and parallelize the computation.'
- A
- 2
In the binary cross-entropy loss function L=−[ylog(y^)+(1−y)log(1−y^)], what does y^ represent?
- A
The learning rate
- B
The linear combination z before activation
- C
The predicted probability output of the network
- D
The ground truth label
Correct answer
CThe predicted probability output of the network
Explanation
y^ is the output of the network, interpreted as a probability. The lecture defines y^=a3=sigmoid(z3).
- A
- 3
Why is the derivative of the cost function J with respect to w3 computed before w1 during backpropagation?
- A
Because w3 updates are larger in magnitude
- B
Because w3 is a scalar
- C
Because w3 is closer to the output and the chain rule starts from the loss
- D
Because w3 has more parameters than w1
Correct answer
CBecause w3 is closer to the output and the chain rule starts from the loss
Explanation
Backpropagation uses the chain rule starting from the loss. The derivative of the loss with respect to w3 is easier to compute because it is directly connected to the output, unlike w1 which requires many intermediate derivatives.
- A
- 4
When computing ∂w3∂L, what is the derivative of the sigmoid activation a3=σ(z3) with respect to z3?
- A
1−a3
- B
e−z3/(1+e−z3)2
- C
a3
- D
a3(1−a3)
Correct answer
Da3(1−a3)
Explanation
The derivative of the sigmoid function is σ(z)(1−σ(z)), which is a3(1−a3).
- A
- 5
In the context of backpropagation, what does caching refer to?
- A
Storing the gradients to reuse in later updates
- B
Temporarily freezing some layers to prevent overfitting
- C
Saving intermediate values from forward propagation for use during backward propagation
- D
Storing the loss values for each iteration
Correct answer
CSaving intermediate values from forward propagation for use during backward propagation
Explanation
The lecture explains that during forward propagation, values like a1, a2, z2, etc., are cached so they can be reused during backward propagation, avoiding recomputation.
- A
- 6
When applying the chain rule to find ∂w2∂L, which intermediate derivative involves an element-wise product?
- A
∂w3∂z3
- B
∂z2∂a2
- C
∂a3∂L
- D
∂a2∂z3
Correct answer
B∂z2∂a2
Explanation
The derivative of the sigmoid activation at layer 2, ∂z2∂a2=a2(1−a2), is an element-wise product because a2 and z2 are vectors.
- A
- 7
What is the shape of the weight matrix w3 in the lecture's 3-layer network (3→2→1)?
- A
2×3
- B
1×3
- C
1×2
- D
2×1
Correct answer
C1×2
Explanation
Layer 3 has 2 inputs and 1 output, so w3 is 1×2. The lecture confirms: '1 by 2. Yeah, it's connecting two neurons to one neuron.'
- A
- 8
Why must activation functions be non-linear in a neural network?
- A
To allow the network to represent complex, non-linear functions
- B
To reduce the number of parameters needed
- C
To make the loss function convex
- D
To ensure the network can be trained with backpropagation
Correct answer
ATo allow the network to represent complex, non-linear functions
Explanation
Without non-linear activation functions, the entire network would collapse into a linear transformation, regardless of depth. The lecture states: 'if you don't choose activation functions, no matter how deep is your network, it's going to be equivalent to a linear regression.'
- A
- 9
Which activation function has the derivative 1−tanh2(z)?
- A
ReLU
- B
Sigmoid
- C
Tanh
- D
Linear
Correct answer
CTanh
Explanation
The lecture gives the derivative of tanh as 1−tanh2(z).
- A
- 10
What is a major disadvantage of the sigmoid activation function?
- A
It outputs values only between -1 and 1
- B
It requires more computation than other activations
- C
It can cause vanishing gradients when activations saturate
- D
It is not differentiable at zero
Correct answer
CIt can cause vanishing gradients when activations saturate
Explanation
The lecture explains that sigmoid saturates at high or low z values, leading to very small gradients, which 'makes it super hard to update my parameters that are early in the network because the gradient is just going to vanish.'
- A
- 11
For what type of output is the sigmoid activation function most appropriate?
- A
Outputs that are unbounded above
- B
Outputs that can be negative or positive
- C
Outputs representing probabilities between 0 and 1
- D
Outputs that should be strictly positive
Correct answer
COutputs representing probabilities between 0 and 1
Explanation
Sigmoid maps any real number to (0,1), making it suitable for probability outputs. The lecture mentions: 'it casts a number ... into 0,1 interval which can be interpreted as a probability.'
- A
- 12
Which activation function is often used in hidden layers to mitigate the vanishing gradient problem?
- A
Sigmoid
- B
Linear
- C
ReLU
- D
Tanh
Correct answer
CReLU
Explanation
ReLU does not saturate for positive inputs; its derivative is constant (1 for positive z), which helps prevent vanishing gradients. The lecture notes: 'ReLU on the other hand doesn't have this problem. If z is very big in the positives, there is no saturation.'
- A
- 13
What is the output range of the tanh activation function?
- A
(0, 1)
- B
[0, ∞)
- C
(-1, 1)
- D
(-∞, ∞)
Correct answer
C(-1, 1)
Explanation
The lecture states that tanh 'goes between minus 1 and plus 1.'
- A
- 14
If a neural network uses identity activation functions throughout, what type of model does it become?
- A
Logistic regression
- B
A non-linear model with increased expressivity
- C
A deep linear regression model
- D
A model equivalent to a single-layer linear network
Correct answer
DA model equivalent to a single-layer linear network
Explanation
The lecture shows that with identity activations, the entire network simplifies to a linear transformation: y^=wL⋯w1x, which is equivalent to a single-layer linear regression.
- A
- 15
In the lecture's example, why does using weights slightly greater than 1 in a deep network with identity activation lead to exploding outputs?
- A
Because the gradients accumulate during backpropagation
- B
Because the loss function amplifies large values
- C
Because the biases are set to zero
- D
Because the forward computation involves repeated matrix multiplication
Correct answer
DBecause the forward computation involves repeated matrix multiplication
Explanation
The lecture explains that with identity activations, y^=WLWL−1⋯W1x. If each weight matrix has eigenvalues >1, the product grows exponentially with depth, causing exploding outputs.
- A
- 16
He initialization recommends initializing weights for ReLU activations using which formula?
- A
n[l−1]+n[l]2
- B
n[l]1
- C
n[l−1]1
- D
n[l−1]2
Correct answer
Dn[l−1]2
Explanation
The lecture states: 'if you use ReLU, it's been observed that putting a 2 here instead of a 1 would make the network train better.' The formula is 2/n[l−1].
- A
- 17
Which initialization method takes both the number of inputs and outputs into account?
- A
Xavier initialization for tanh
- B
Zero initialization
- C
He initialization
- D
Glorot initialization
Correct answer
DGlorot initialization
Explanation
The lecture describes Glorot initialization as using the geometric average of input and output dimensions: 2/(n[l−1]+n[l]).
- A
- 18
Why is random initialization preferred over zero initialization for weights?
- A
To avoid the vanishing gradient problem
- B
To break symmetry so neurons learn different features
- C
To reduce the memory footprint
- D
To increase the learning rate
Correct answer
BTo break symmetry so neurons learn different features
Explanation
The lecture mentions 'the symmetry problem where every neuron is going to learn kind of the same thing. To avoid that, you will make the neuron starts at different places.'
- A
- 19
What is the purpose of input normalization in neural network training?
- A
To make the loss function contours more spherical and easier to optimize
- B
To reduce the number of parameters
- C
To convert categorical data to numerical
- D
To increase the number of training examples
Correct answer
ATo make the loss function contours more spherical and easier to optimize
Explanation
The lecture shows that normalization (subtract mean, divide by variance) transforms the loss contour from elongated to spherical, allowing gradient descent to move directly toward the minimum.
- A
- 20
When normalizing test data, which statistics should be used?
- A
The mean of the training set but variance of the test set
- B
The mean and variance of the training set
- C
The mean and variance of the test set
- D
Neither; normalization is not applied to test data
Correct answer
BThe mean and variance of the training set
Explanation
The lecture emphasizes: 'you should not compute the mean of the test set... Instead, you should use the Mu and the Sigma that were computed on the train set.'
- A
- 21
In mini-batch gradient descent, what is the key advantage of using batches over stochastic gradient descent?
- A
Smaller memory footprint
- B
No need to tune the learning rate
- C
Guaranteed convergence to the global minimum
- D
Vectorization leads to faster computation per iteration
Correct answer
DVectorization leads to faster computation per iteration
Explanation
The lecture explains that mini-batch gradient descent provides a trade-off: it allows vectorization (like batch GD) while still having quick updates (like SGD).
- A
- 22
In the notation for mini-batch gradient descent, what does X{t} represent?
- A
The t-th training example
- B
The t-th batch of training examples
- C
The t-th epoch
- D
The transposed input matrix
Correct answer
BThe t-th batch of training examples
Explanation
The lecture defines X{t} as the t-th batch: 'x_1 until x maybe T like that. Assuming it's a batch of 1,000 examples.'
- A
- 23
How does the cost function plot typically differ between batch gradient descent and mini-batch gradient descent?
- A
Batch GD decreases monotonically; mini-batch GD decreases with noise
- B
Mini-batch GD increases initially then decreases
- C
Both are identical if the batch size is 1
- D
Batch GD has more noise; mini-batch GD is smoother
Correct answer
ABatch GD decreases monotonically; mini-batch GD decreases with noise
Explanation
The lecture shows that for batch GD the cost decreases smoothly, while for mini-batch GD it decreases with oscillations due to gradient approximation.
- A
- 24
In the momentum optimization algorithm, what role does the velocity term v play?
- A
It accumulates an exponentially weighted average of past gradients
- B
It stores the squared gradients for adaptive learning rates
- C
It controls the batch size dynamically
- D
It directly replaces the learning rate
Correct answer
AIt accumulates an exponentially weighted average of past gradients
Explanation
The lecture states that momentum uses 'a variable called velocity, which is going to be the average of the previous velocity and the current weight updates.' This is an exponential moving average.
- A
- 25
Momentum helps reduce oscillations in gradient descent by:
- A
Averaging gradients over time, canceling perpendicular oscillations
- B
Increasing the learning rate on steep dimensions
- C
Randomly shuffling the training data
- D
Using a second-order approximation of the loss
Correct answer
AAveraging gradients over time, canceling perpendicular oscillations
Explanation
The lecture explains that on a contour with one elongated direction, gradients oscillate in the narrow direction. Averaging them cancels those oscillations while reinforcing movement in the consistent direction.
- A
- 26
In the momentum update rule v=βv+(1−β)dw, what does β typically represent?
- A
The learning rate
- B
The decay factor for past gradients
- C
The batch size
- D
The regularization strength
Correct answer
BThe decay factor for past gradients
Explanation
The lecture refers to β as a factor that weights the importance of past velocity. A typical value is 0.9, controlling the exponential decay.
- A
- 27
How does the update rule for momentum differ from standard gradient descent?
- A
It first updates a velocity term, then uses that velocity to update the weights
- B
It subtracts the gradient directly without any modification
- C
It computes the gradient over multiple batches before updating
- D
It uses a separate learning rate for each parameter
Correct answer
AIt first updates a velocity term, then uses that velocity to update the weights
Explanation
Standard GD: w=w−αdw. Momentum: v=βv+(1−β)dw, then w=w−αv. The velocity is updated first.
- A

Ask anything
We've read this whole study set, so questions about it get the best answers.