TensorFlow.js 打印整个张量 [英] TensorFlow.js print whole tensor
本文介绍了TensorFlow.js 打印整个张量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试打印我使用 tf.fromPixels
获得的张量以进行调试.但是因为张量太大就做
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?
推荐答案
如果你真的只想要这些值,你可以使用 .data()
或 .dataSync()
将所有值下载为一维 TypedArray:
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());
但是由于您的 Tensor 实际上代表一个图像,您可以在 元素中直观地显示它:
but since your Tensor actually represents an image you can show it visually in a <canvas>
element:
tf.toPixels(a, document.getElementsByTagName("canvas")[0]);
这篇关于TensorFlow.js 打印整个张量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文