Provided f(x1, x2,...), returns another function g([x1, x2,...], dy?),
which gives an array of gradients of f() with respect to each input
[x1,x2,...].
If dy is passed when calling g(), the gradient of
f(x1,...).mul(dy).sum() with respect to each input is computed instead.
The provided f must take one or more tensors and return a single tensor
y. If f() takes a single input, we recommend using tf.grad instead.
// f(a, b) = a * b constf = (a, b) =>a.mul(b); // df / da = b, df / db = a constg = tf.grads(f);
Provided
f(x1, x2,...), returns another functiong([x1, x2,...], dy?), which gives an array of gradients off()with respect to each input [x1,x2,...].If
dyis passed when callingg(), the gradient off(x1,...).mul(dy).sum()with respect to each input is computed instead. The providedfmust take one or more tensors and return a single tensory. Iff()takes a single input, we recommend usingtf.gradinstead.