Backpropagation pt. 1�
Prof. André E. Lazzaretti
Loss function
or for short:
Returns a scalar that is smaller when model maps inputs to outputs better
Example
Problem 1: Computing gradients
Loss: sum of individual terms:
SGD Algorithm:
Parameters:
Need to compute gradients
Why is this such a big deal?
Gradients
Problem 1: Computing gradients
Loss: sum of individual terms:
SGD Algorithm:
Parameters:
Need to compute gradients
Algorithm to compute gradient efficiently
BackProp intuition #1: the forward pass
BackProp intuition #2: the backward pass
To calculate how a small change in a weight or bias feeding into hidden layer h3 modifies the loss, we need to know:�
BackProp intuition #2: the backward pass
To calculate how a small change in a weight or bias feeding into hidden layer h2 modifies the loss, we need to know:
BackProp intuition #2: the backward pass
To calculate how a small change in a weight or bias feeding into hidden layer h1 modifies the loss, we need to know:
Gradients
Toy function
Toy function
Derivatives
Gradients of toy function
We want to calculate:
Gradients of composed functions
Calculating expressions by hand:
Forward pass
1. Write this as a series of
intermediate calculations
2. Compute these intermediate quantities
Backward pass
1. Compute the derivatives of the loss with respect to these intermediate quantities, but in reverse order.
Backward pass
1. Compute the derivatives of the loss with respect to these intermediate quantities, but in reverse order.
Backward pass
1. Compute the derivatives of the loss with respect to these intermediate quantities, but in reverse order.
Backward pass
1. Compute the derivatives of the loss with respect to these intermediate quantities, but in reverse order.
Backward pass
1. Compute the derivatives of the loss with respect to these intermediate quantities, but in reverse order.
Already computed!
ω3
Backward pass
1. Compute the derivatives of the loss with respect to these intermediate quantities, but in reverse order.
Backward pass
1. Compute the derivatives of the loss with respect to these intermediate quantities, but in reverse order.
Already computed!
-sin[f2]
Backward pass
1. Compute the derivatives of the loss with respect to these intermediate quantities, but in reverse order.
Backward pass
1. Compute the derivatives of the loss with respect to these intermediate quantities, but in reverse order.
Backward pass
1. Compute the derivatives of the loss with respect to these intermediate quantities, but in reverse order.
Backward pass
2. Find how the loss changes as a function of the parameters β and ω.
Backward pass
2. Find how the loss changes as a function of the parameters β and ω.
Already calculated in part 1.
hk
Backward pass
2. Find how the loss changes as a function of the parameters β and ω.
Backward pass
2. Find how the loss changes as a function of the parameters β and ω.
Check!
Write the gradient equation to update ω2 (first, calculate δli / δω2)
Final answer: −2 h2 ω3 sin(f2) (f3 − yi)
Backpropagation
Backpropagation
Backpropagation
Backpropagation
Backpropagation
Backpropagation
Backpropagation
Backpropagation
Backpropagation
Backpropagation
Backpropagation
Backpropagation
Backpropagation
Backpropagation
Backpropagation
Backpropagation
Backpropagation
Backpropagation
Backpropagation
Backpropagation
Backpropagation
Backpropagation
Backpropagation