Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TensorFlow.js print whole tensor

I'm trying to print a tensor I got using tf.fromPixels for debugging purposes. But because the tensor is too big just doing

a = tf.fromPixels(image, 3);
a.print();

doesn't work, because it is being shortened in the console. Is there a workaround for this?

like image 794
allinonemovie Avatar asked Sep 01 '25 01:09

allinonemovie


1 Answers

If you really only want the values you can use .data() or .dataSync() to download all values as a one dimensional TypedArray:

console.log(a.dataSync());

but since your Tensor actually represents an image you can show it visually in a <canvas> element:

tf.toPixels(a, document.getElementsByTagName("canvas")[0]);
like image 113
Sebastian Speitel Avatar answered Sep 04 '25 09:09

Sebastian Speitel