学习维度转换
shape 计算维度
代码语言:javascript复制tf.shape(input,name = None)
案例1
代码语言:javascript复制a = tf.constant([i for i in range(20)],shape =[2,2,5])
with tf.Session() as sess:
print (sess.run(tf.shape(a)))
结果:[2 2 5]
size 计算元素个数
代码语言:javascript复制tf.size(input,name = None)
案例2
代码语言:javascript复制a = tf.constant([i for i in range(20)],shape =[2,2,5])
with tf.Session() as sess:
print (sess.run(tf.size(a)))
结果:20
rank 计算秩
代码语言:javascript复制tf.rank(input, name=None)
案例3
代码语言:javascript复制a = tf.constant([i for i in range(20)],shape =[2,2,5])
with tf.Session() as sess:
print (sess.run(tf.rank(a)))
结果 : 3
reshape重新的规则排列
代码语言:javascript复制tf.reshape(tensor, shape, name=None)
案例4
代码语言:javascript复制a = tf.constant([i for i in range(20)],shape =[2,2,5])
with tf.Session() as sess:
print (sess.run(tf.reshape(a,shape = [5,2,2])))
原始的数据
结果:
squeeze
没理解,等理解了再来更新。
代码语言:javascript复制tf.squeeze(input, squeeze_dims=None, name=None)
expand_dims
没理解,等理解了再来更新。
代码语言:javascript复制tf.expand_dims(input, dim, name=None)