TensorFlow:将标量转换为一维张量的最佳方法

3
我需要将 Tensorflow 中的标量转换成只有一个元素的一维张量。请问有什么最好的方法吗?
1个回答

2
您可以使用 tf.reshape
例如:
import tensorflow as tf
x = tf.constant(2)
x_1d = tf.reshape(x, [1])

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接