MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / softplus_grad

Function softplus_grad

imperative/python/megengine/xla/rules/elemwise.py:407–415  ·  view source on GitHub ↗
(x, dy)

Source from the content-addressed store, hash-verified

405
406
407def softplus_grad(x, dy):
408 from .tensor import where
409
410 exp_abs = exp(-abs(x))
411 logg = -dy * exp_abs / (1.0 + exp_abs)
412 grad0 = where(x > 0.0, logg, -logg)
413 relux = relu(x)
414 grad1 = where(relux > 0.0, dy, 0.0)
415 return (grad0 + grad1).astype(x.dtype)
416
417
418def prelu(inp, alpha):

Callers

nothing calls this directly

Calls 5

whereFunction · 0.70
reluFunction · 0.70
expFunction · 0.50
absFunction · 0.50
astypeMethod · 0.45

Tested by

no test coverage detected