Compute the input-gradient contributions for one saved scalar operation: add and mul take two inputs, while tanh takes one. The supplied output is its saved forward result.
add contributions=[g,g] mul contributions=[gb,ga] tanh contribution=[g(1−t2)]Here a and b are the first and second inputs, g is upstream_gradient, and t is the saved tanh output. Return a Python list of 64-bit floating-point contributions, one per input in input order.
Input: operation = "add", inputs = [2.0, -3.0], output = -1.0, upstream_gradient = 4.0
Output: [4.0, 4.0]
Explanation: Both local derivatives of addition are one.
Input: operation = "mul", inputs = [-2.0, 3.0], output = -6.0, upstream_gradient = 0.5
Output: [1.5, -1.0]
Input: operation = "tanh", inputs = [1.0], output = 0.7615941559557649, upstream_gradient = 2.0
Output: [0.839949]
List indexing identifies the other operand in a multiplication.
The saved tanh output can be squared directly; no new activation call is needed.
Accepts: string
Accepts: array
Accepts: number
Accepts: number
Compute the input-gradient contributions for one saved scalar operation: add and mul take two inputs, while tanh takes one. The supplied output is its saved forward result.
add contributions=[g,g] mul contributions=[gb,ga] tanh contribution=[g(1−t2)]Here a and b are the first and second inputs, g is upstream_gradient, and t is the saved tanh output. Return a Python list of 64-bit floating-point contributions, one per input in input order.
Input: operation = "add", inputs = [2.0, -3.0], output = -1.0, upstream_gradient = 4.0
Output: [4.0, 4.0]
Explanation: Both local derivatives of addition are one.
Input: operation = "mul", inputs = [-2.0, 3.0], output = -6.0, upstream_gradient = 0.5
Output: [1.5, -1.0]
Input: operation = "tanh", inputs = [1.0], output = 0.7615941559557649, upstream_gradient = 2.0
Output: [0.839949]
List indexing identifies the other operand in a multiplication.
The saved tanh output can be squared directly; no new activation call is needed.
Accepts: string
Accepts: array
Accepts: number
Accepts: number