1. Home
  2. Explore
  3. Computer Science
  4. Deep Learning Lecture 2

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Deep Learning Lecture 2

  • 27Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: Backpropagation

What is the primary reason for using batches of examples in neural network training?

27 questions

  1. 1

    What is the primary reason for using batches of examples in neural network training?

    1. A

      To make the cost function more convex

    2. B

      To reduce overfitting by averaging gradients

    3. C

      To enable vectorized computation for parallel processing on GPUs

    4. D

      To decrease the number of parameters needing updates

    Correct answer
    C

    To 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.'

  2. 2

    In the binary cross-entropy loss function L=−[ylog⁡(y^)+(1−y)log⁡(1−y^)]L = -[y \log(\hat{y}) + (1-y)\log(1-\hat{y})]L=−[ylog(y^​)+(1−y)log(1−y^​)], what does y^\hat{y}y^​ represent?

    1. A

      The learning rate

    2. B

      The linear combination zzz before activation

    3. C

      The predicted probability output of the network

    4. D

      The ground truth label

    Correct answer
    C

    The predicted probability output of the network

    Explanation

    y^\hat{y}y^​ is the output of the network, interpreted as a probability. The lecture defines y^=a3=sigmoid(z3)\hat{y} = a_3 = \text{sigmoid}(z_3)y^​=a3​=sigmoid(z3​).

  3. 3

    Why is the derivative of the cost function JJJ with respect to w3w_3w3​ computed before w1w_1w1​ during backpropagation?

    1. A

      Because w3w_3w3​ updates are larger in magnitude

    2. B

      Because w3w_3w3​ is a scalar

    3. C

      Because w3w_3w3​ is closer to the output and the chain rule starts from the loss

    4. D

      Because w3w_3w3​ has more parameters than w1w_1w1​

    Correct answer
    C

    Because w3w_3w3​ 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 w3w_3w3​ is easier to compute because it is directly connected to the output, unlike w1w_1w1​ which requires many intermediate derivatives.

  4. 4

    When computing ∂L∂w3\frac{\partial L}{\partial w_3}∂w3​∂L​, what is the derivative of the sigmoid activation a3=σ(z3)a_3 = \sigma(z_3)a3​=σ(z3​) with respect to z3z_3z3​?

    1. A

      1−a31 - a_31−a3​

    2. B

      e−z3/(1+e−z3)2e^{-z_3} / (1 + e^{-z_3})^2e−z3​/(1+e−z3​)2

    3. C

      a3a_3a3​

    4. D

      a3(1−a3)a_3 (1 - a_3)a3​(1−a3​)

    Correct answer
    D

    a3(1−a3)a_3 (1 - a_3)a3​(1−a3​)

    Explanation

    The derivative of the sigmoid function is σ(z)(1−σ(z))\sigma(z)(1-\sigma(z))σ(z)(1−σ(z)), which is a3(1−a3)a_3(1-a_3)a3​(1−a3​).

  5. 5

    In the context of backpropagation, what does caching refer to?

    1. A

      Storing the gradients to reuse in later updates

    2. B

      Temporarily freezing some layers to prevent overfitting

    3. C

      Saving intermediate values from forward propagation for use during backward propagation

    4. D

      Storing the loss values for each iteration

    Correct answer
    C

    Saving intermediate values from forward propagation for use during backward propagation

    Explanation

    The lecture explains that during forward propagation, values like a1a_1a1​, a2a_2a2​, z2z_2z2​, etc., are cached so they can be reused during backward propagation, avoiding recomputation.

  6. 6

    When applying the chain rule to find ∂L∂w2\frac{\partial L}{\partial w_2}∂w2​∂L​, which intermediate derivative involves an element-wise product?

    1. A

      ∂z3∂w3\frac{\partial z_3}{\partial w_3}∂w3​∂z3​​

    2. B

      ∂a2∂z2\frac{\partial a_2}{\partial z_2}∂z2​∂a2​​

    3. C

      ∂L∂a3\frac{\partial L}{\partial a_3}∂a3​∂L​

    4. D

      ∂z3∂a2\frac{\partial z_3}{\partial a_2}∂a2​∂z3​​

    Correct answer
    B

    ∂a2∂z2\frac{\partial a_2}{\partial z_2}∂z2​∂a2​​

    Explanation

    The derivative of the sigmoid activation at layer 2, ∂a2∂z2=a2(1−a2)\frac{\partial a_2}{\partial z_2} = a_2(1-a_2)∂z2​∂a2​​=a2​(1−a2​), is an element-wise product because a2a_2a2​ and z2z_2z2​ are vectors.

  7. 7

    What is the shape of the weight matrix w3w_3w3​ in the lecture's 3-layer network (3→2→1)?

    1. A

      2×32 \times 32×3

    2. B

      1×31 \times 31×3

    3. C

      1×21 \times 21×2

    4. D

      2×12 \times 12×1

    Correct answer
    C

    1×21 \times 21×2

    Explanation

    Layer 3 has 2 inputs and 1 output, so w3w_3w3​ is 1×21 \times 21×2. The lecture confirms: '1 by 2. Yeah, it's connecting two neurons to one neuron.'

  8. 8

    Why must activation functions be non-linear in a neural network?

    1. A

      To allow the network to represent complex, non-linear functions

    2. B

      To reduce the number of parameters needed

    3. C

      To make the loss function convex

    4. D

      To ensure the network can be trained with backpropagation

    Correct answer
    A

    To 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.'

  9. 9

    Which activation function has the derivative 1−tanh⁡2(z)1 - \tanh^2(z)1−tanh2(z)?

    1. A

      ReLU

    2. B

      Sigmoid

    3. C

      Tanh

    4. D

      Linear

    Correct answer
    C

    Tanh

    Explanation

    The lecture gives the derivative of tanh as 1−tanh⁡2(z)1 - \tanh^2(z)1−tanh2(z).

  10. 10

    What is a major disadvantage of the sigmoid activation function?

    1. A

      It outputs values only between -1 and 1

    2. B

      It requires more computation than other activations

    3. C

      It can cause vanishing gradients when activations saturate

    4. D

      It is not differentiable at zero

    Correct answer
    C

    It 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.'

  11. 11

    For what type of output is the sigmoid activation function most appropriate?

    1. A

      Outputs that are unbounded above

    2. B

      Outputs that can be negative or positive

    3. C

      Outputs representing probabilities between 0 and 1

    4. D

      Outputs that should be strictly positive

    Correct answer
    C

    Outputs 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.'

  12. 12

    Which activation function is often used in hidden layers to mitigate the vanishing gradient problem?

    1. A

      Sigmoid

    2. B

      Linear

    3. C

      ReLU

    4. D

      Tanh

    Correct answer
    C

    ReLU

    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.'

  13. 13

    What is the output range of the tanh activation function?

    1. A

      (0, 1)

    2. B

      [0, ∞)

    3. C

      (-1, 1)

    4. D

      (-∞, ∞)

    Correct answer
    C

    (-1, 1)

    Explanation

    The lecture states that tanh 'goes between minus 1 and plus 1.'

  14. 14

    If a neural network uses identity activation functions throughout, what type of model does it become?

    1. A

      Logistic regression

    2. B

      A non-linear model with increased expressivity

    3. C

      A deep linear regression model

    4. D

      A model equivalent to a single-layer linear network

    Correct answer
    D

    A 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\hat{y} = w_L \cdots w_1 xy^​=wL​⋯w1​x, which is equivalent to a single-layer linear regression.

  15. 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?

    1. A

      Because the gradients accumulate during backpropagation

    2. B

      Because the loss function amplifies large values

    3. C

      Because the biases are set to zero

    4. D

      Because the forward computation involves repeated matrix multiplication

    Correct answer
    D

    Because the forward computation involves repeated matrix multiplication

    Explanation

    The lecture explains that with identity activations, y^=WLWL−1⋯W1x\hat{y} = W_L W_{L-1} \cdots W_1 xy^​=WL​WL−1​⋯W1​x. If each weight matrix has eigenvalues >1, the product grows exponentially with depth, causing exploding outputs.

  16. 16

    He initialization recommends initializing weights for ReLU activations using which formula?

    1. A

      2n[l−1]+n[l]\sqrt{\frac{2}{n^{[l-1]} + n^{[l]}}}n[l−1]+n[l]2​​

    2. B

      1n[l]\sqrt{\frac{1}{n^{[l]}}}n[l]1​​

    3. C

      1n[l−1]\sqrt{\frac{1}{n^{[l-1]}}}n[l−1]1​​

    4. D

      2n[l−1]\sqrt{\frac{2}{n^{[l-1]}}}n[l−1]2​​

    Correct answer
    D

    2n[l−1]\sqrt{\frac{2}{n^{[l-1]}}}n[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]\sqrt{2 / n^{[l-1]}}2/n[l−1]​.

  17. 17

    Which initialization method takes both the number of inputs and outputs into account?

    1. A

      Xavier initialization for tanh

    2. B

      Zero initialization

    3. C

      He initialization

    4. D

      Glorot initialization

    Correct answer
    D

    Glorot initialization

    Explanation

    The lecture describes Glorot initialization as using the geometric average of input and output dimensions: 2/(n[l−1]+n[l])\sqrt{2/(n^{[l-1]} + n^{[l]})}2/(n[l−1]+n[l])​.

  18. 18

    Why is random initialization preferred over zero initialization for weights?

    1. A

      To avoid the vanishing gradient problem

    2. B

      To break symmetry so neurons learn different features

    3. C

      To reduce the memory footprint

    4. D

      To increase the learning rate

    Correct answer
    B

    To 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.'

  19. 19

    What is the purpose of input normalization in neural network training?

    1. A

      To make the loss function contours more spherical and easier to optimize

    2. B

      To reduce the number of parameters

    3. C

      To convert categorical data to numerical

    4. D

      To increase the number of training examples

    Correct answer
    A

    To 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.

  20. 20

    When normalizing test data, which statistics should be used?

    1. A

      The mean of the training set but variance of the test set

    2. B

      The mean and variance of the training set

    3. C

      The mean and variance of the test set

    4. D

      Neither; normalization is not applied to test data

    Correct answer
    B

    The 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.'

  21. 21

    In mini-batch gradient descent, what is the key advantage of using batches over stochastic gradient descent?

    1. A

      Smaller memory footprint

    2. B

      No need to tune the learning rate

    3. C

      Guaranteed convergence to the global minimum

    4. D

      Vectorization leads to faster computation per iteration

    Correct answer
    D

    Vectorization 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).

  22. 22

    In the notation for mini-batch gradient descent, what does X{t}X^{\{t\}}X{t} represent?

    1. A

      The t-th training example

    2. B

      The t-th batch of training examples

    3. C

      The t-th epoch

    4. D

      The transposed input matrix

    Correct answer
    B

    The t-th batch of training examples

    Explanation

    The lecture defines X{t}X^{\{t\}}X{t} as the t-th batch: 'x_1 until x maybe T like that. Assuming it's a batch of 1,000 examples.'

  23. 23

    How does the cost function plot typically differ between batch gradient descent and mini-batch gradient descent?

    1. A

      Batch GD decreases monotonically; mini-batch GD decreases with noise

    2. B

      Mini-batch GD increases initially then decreases

    3. C

      Both are identical if the batch size is 1

    4. D

      Batch GD has more noise; mini-batch GD is smoother

    Correct answer
    A

    Batch 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.

  24. 24

    In the momentum optimization algorithm, what role does the velocity term vvv play?

    1. A

      It accumulates an exponentially weighted average of past gradients

    2. B

      It stores the squared gradients for adaptive learning rates

    3. C

      It controls the batch size dynamically

    4. D

      It directly replaces the learning rate

    Correct answer
    A

    It 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.

  25. 25

    Momentum helps reduce oscillations in gradient descent by:

    1. A

      Averaging gradients over time, canceling perpendicular oscillations

    2. B

      Increasing the learning rate on steep dimensions

    3. C

      Randomly shuffling the training data

    4. D

      Using a second-order approximation of the loss

    Correct answer
    A

    Averaging 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.

  26. 26

    In the momentum update rule v=βv+(1−β)dwv = \beta v + (1-\beta) dwv=βv+(1−β)dw, what does β\betaβ typically represent?

    1. A

      The learning rate

    2. B

      The decay factor for past gradients

    3. C

      The batch size

    4. D

      The regularization strength

    Correct answer
    B

    The decay factor for past gradients

    Explanation

    The lecture refers to β\betaβ as a factor that weights the importance of past velocity. A typical value is 0.9, controlling the exponential decay.

  27. 27

    How does the update rule for momentum differ from standard gradient descent?

    1. A

      It first updates a velocity term, then uses that velocity to update the weights

    2. B

      It subtracts the gradient directly without any modification

    3. C

      It computes the gradient over multiple batches before updating

    4. D

      It uses a separate learning rate for each parameter

    Correct answer
    A

    It first updates a velocity term, then uses that velocity to update the weights

    Explanation

    Standard GD: w=w−αdww = w - \alpha dww=w−αdw. Momentum: v=βv+(1−β)dwv = \beta v + (1-\beta) dwv=βv+(1−β)dw, then w=w−αvw = w - \alpha vw=w−αv. The velocity is updated first.

Question 1 of 27
Question 1 of 27

Ask anything

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

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent