Backpropagate through tanh

Problem

A scalar network has h=tanh⁡(wx)h=\tanh(wx), y^=vh\hat{y}=vh, and L=12(y^−y)2L=\frac{1}{2}(\hat{y}-y)^2. At x=1x=1, w=0w=0, v=2v=2, and y=1y=1, compute the forward pass, ∂L∂v\frac{\partial L}{\partial v}, and ∂L∂w\frac{\partial L}{\partial w}.

Reveal answer or reference solution

The forward pass gives h=0h=0, y^=0\hat{y}=0, and L=12L=\frac{1}{2}. By the chain rule,

∂L∂v=(y^−y)h=0.\frac{\partial L}{\partial v}=(\hat{y}-y)h=0.

Also,

∂L∂w=(y^−y)v(1−h2)x=(−1)(2)(1)(1)=−2.\frac{\partial L}{\partial w}=(\hat{y}-y)v(1-h^2)x=(-1)(2)(1)(1)=-2.

The output weight has zero gradient because its input activation is zero.

Outcome

Previous attempts

Loading attempts saved in this browser…

    Review Screening Results