如何将numpy数组转换为张量?

时间:2021-02-14 05:43:24

标签: python numpy tensorflow

我尝试使用 conver_to_tensor 函数

k = np.array([1,5,6,9,])
print(list(k))
k = list(k)
k = tf.convert_to_tensor(k)
k

输出:

[1, 5, 6, 9]
<tf.Tensor: shape=(4,), dtype=int32, numpy=array([1, 5, 6, 9], dtype=int32)>

在这里我将它转换为张量,但在里面它仍然只包含在 numpy 数组中。 有没有办法完全转换为张量? 基本上我想要一个包含数字列表/数组的张量。

0 个答案:

没有答案