为什么tf.ones
返回零?我的版本是'2.3.0'
,我使用的是Python环境
import tensorflow as tf
tf.ones((3, 3))
<tf.Tensor: shape=(3, 3), dtype=float32, numpy=
array([[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.]], dtype=float32)>
我不明白发生了什么。。。但是如果我使用dtypetf.int32
,它可以工作:
tf.ones((3, 3), dtype=tf.int32)
<tf.Tensor: shape=(3, 3), dtype=int32, numpy=
array([[1, 1, 1],
[1, 1, 1],
[1, 1, 1]])>
有人有同样的问题
也许,您的Python安装不支持tensorflow 2.3.0。例如,Anaconda仅在TF2.1.0下才能正常工作
相关问题 更多 >
编程相关推荐