a = tf.Variable(np.random.random([2,3]), dtype = np.float32) 不会报错。因为没有dtype的话,np.float32返回一个str, 会被当作布尔变量True传递给 Train。如下
tf.Variable
__init__(
initial_value=None,
trainable=True,
collections=None,
validate_shape=True,
caching_device=None,
name=None,
variable_def=None,
dtype=None,
expected_shape=None,
import_scope=None
)
TensorFlow学习中遇到的坑(二)np.float32 和 tf.float32有什么区别 因为熟悉了numpy,所以在tensorflow中张量初始化更喜欢用numpy来做,可是你这么写: 就会始终报错!显...