1、得到tensor维度
feature.get_shape()
tf.shape()
2、lamda表达式
lamda x,y:x+y
lamda (参数):(函数表达式)
3、将python任意类型的数据转变成tensor
tf.conver_to_tensor(value,dtype=None,name=None,prefered_dtype=None)
4、tensorflow 模块功能相似
tf.nn.layers 和 tf.contrib 模块很多功能是重复的。tf.nn比较基础,tf.layers提供高层的神经网络,是对tf.nn
的进一步封装,tf.contrib是高级操作,封装更加完善,但是包含不稳定的实验代码,有可能以后API会改变。
5、生成器以及迭代器
显示生成器数值使用next()即可
6、 shape属性
list没有shape属性,想看的话可以使用np.shape()函数,array有shape属性,比如a.shape
7、 tf.stack()
Stacks a list of rank-R tensors into one rank-(R+1) tensor.
x = tf.constant([1, 4])
y = tf.constant([2, 5])
z = tf.constant([3, 6])
tf.stack([x, y, z]) # [[1, 4], [2, 5], [3, 6]] (Pack along first dim.)
tf.stack([x, y, z], axis=1) # [[1, 2, 3], [4, 5, 6]]