Hand-derive the gradient of L = sum(tanh(x)) w.r.t. x.
Forward: y = tanh(x). L = sum(y).
Implement:
tanh_forward(x) -> ytanh_backward(x) -> dL/dx of the same shapeUse the identity dy/dx = 1 - y^2.
Math
Related problems
Asked at
import numpy as np
def tanh_forward(...):
pass
Premium problem
Free accounts include problems #1–20. Upgrade to unlock the editor, hidden test cases, and reference solutions for every problem.
Already premium?