float32, numpy=1.0>
tf.constant(2., dtype=tf.double) # 创建的同时指定数据类型
<tf.Tensor: id=4, shape=(), dtype=float64...(np.ones([2, 3]))
<tf.Tensor: id=9, shape=(2, 3), dtype=float64, numpy=
array([[1., 1., 1.],
[...1., 1., 1.]])>
tf.convert_to_tensor(np.ones([2, 3]))
<tf.Tensor: id=11, shape=(2, 3), dtype=float64,...4.2 转置:transpose()
transpose()方法提供了一种类似于装置的操作:
a = tf.constant([[1,2,3],[4,5,6]])
a.shape
TensorShape..., numpy=
array([[1, 4],
[2, 5],
[3, 6]])>
在默认情况下,transpose()方法会将所有维度按逆序方式完全转置,当然也可以通过perm