先从TensorFlow的基本数据结构——张量(tensor)开始。...2 创建
2.1 constant()方法
import tensorflow as tf
tf.constant(1) # 创建一个整型张量
张量
tf.constant(2., dtype=tf.double...4.2 转置:transpose()
transpose()方法提供了一种类似于装置的操作:
a = tf.constant([[1,2,3],[4,5,6]])
a.shape
TensorShape...,当然也可以通过perm参数执行需要转置的维度:
a=tf.constant([[[1,2,3],[4,5,6]],[[7,8,9],[10,11,12]]])
a
<tf.Tensor: id=194