Hand-derive the gradient of L = sum(sigmoid(x)) w.r.t. x.
Forward: y = 1 / (1 + exp(-x)). L = sum(y).
Implement:
sigmoid_forward(x) -> ysigmoid_backward(x) -> dL/dx of the same shapeThe classic identity: dy/dx = y * (1 - y). Use it to keep the backward cheap and numerically stable.
Math
Related problems
Asked at
import numpy as np
def sigmoid_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?