How do I get the value out of a tensor in Tensorflow.js after specifying the index?
The . tidy() function is used to execute the given function i.e. fn and once its terminated it clears up all the equidistant tensors that are allotted by the stated function fn excluding the ones that are returned by fn.
A tensor is a vector or matrix of n-dimensions that represents all types of data. All values in a tensor hold identical data type with a known (or partially known) shape. The shape of the data is the dimensionality of the matrix or array. A tensor can be originated from the input data or the result of a computation.
You can use datasync for this.
const newTensor = tf.tensor2d([[2,4],[5,6]]);
const tensorData = newTensor.dataSync();
console.log("data[0] is " + tensorData[0]);
console.log("data[3] is " + tensorData[3]);
https://codepen.io/anon/pen/NMKgeO?editors=1011
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With