目录
1、tf.slice
2、tf.reshape
3、tf.transpose
4、tf.cast
5、tf.argmax
6、tf.truncated_normal
7、tf.nn.conv2d
8、tf.nn.softmax
9、tf.reduce_sum/tf.reduce_mean
1、tf.slice(input, begin, slice_dimension)
····
import tensorflow as tf
a = tf.constant([[1, 2, 3], [-1, -2, -2], [3, 2, 1]])
sess = tf.InteractiveSession()
b = tf.slice(a, [1, 0], [2, 3])
#[1, 0]表示从矩阵的[1, 0]开始计算截取位置
#注:由于是二维矩阵,所以此时只能填充二维数组
#[2, 3]表示在[1, 0]的基准位置取2行三列元素
sess.run(a)
sess.run(b)
'''
array([[ 1, 2, 2],
[-1, -2, -3],
[ 3, 2, 1]])
array([[-1, -2, -3],
[ 3, 2, 1]])
'''
····
2、tf.reshape(input, shape)
注:shape为待转换的矩阵形状,其参数具体根据输入确定。并且其中有且仅允许存在一个‘-1’,表示在该维度上由计算机得出。并且在shape中的元素值乘积等于输入矩阵个数,且shape中元素的个数为输出数组维度
import tensorflow as tf
a = tf.constant([[1, 2, 3, 4], [4, 3, 2, 1]