Like tf.grads, but returns also the value of f(). Useful when f() returns a metric you want to show.
tf.grads
f()
The result is a rich object with the following properties:
f(x)
// f(a, b) = a * bconst f = (a, b) => a.mul(b);// df/da = b, df/db = aconst g = tf.valueAndGrads(f);const a = tf.tensor1d([2, 3]);const b = tf.tensor1d([-2, -3]);const {value, grads} = g([a, b]);const [da, db] = grads;console.log('value');value.print();console.log('da');da.print();console.log('db');db.print(); Copy
// f(a, b) = a * bconst f = (a, b) => a.mul(b);// df/da = b, df/db = aconst g = tf.valueAndGrads(f);const a = tf.tensor1d([2, 3]);const b = tf.tensor1d([-2, -3]);const {value, grads} = g([a, b]);const [da, db] = grads;console.log('value');value.print();console.log('da');da.print();console.log('db');db.print();
Rest
Optional
Generated using TypeDoc
Like
tf.grads
, but returns also the value off()
. Useful whenf()
returns a metric you want to show.The result is a rich object with the following properties:
f()
w.r.t. each input (result oftf.grads
).f(x)
.