x.shape=[2,3,4]
修改视图
tf.reshape(x,newShape)
增加维度
tf.expand_dims(x,axis)指定axis前插入维度
tf.expand_dims(x,0) 后 x.shape=[1,2,3,4]
删除维度
tf.squeeze(x,axis),只能删除长度为1的维度,不指定axis时删除所有长度为1的维度
tf.squeeze(x,0) 后 x.shape=[2,3,4]
交换维度
tf.transpose(x,perm=)
perm参数为新维度的顺序,list
x.shape=[2,3,4]
tf.transpose(x,perm=[1,2,0])
x.shape=[3,4,2]
复制数据
tf.tile(x,multiples)
multiples与x的shape一致,参数
表示在对应维度中复制的次数,1表示不复制
[En]
Indicates the number of times replicated in the corresponding dimension, and 1 indicates no replication
a = tf.constant([[1,2],[3,4]])
b = tf.tile(a,[2,3])
[[1 2 ]
[3 4 ]]
[[1 2 1 2 1 2]
[3 4 3 4 3 4]
[1 2 1 2 1 2]
[3 4 3 4 3 4]]
Original: https://blog.csdn.net/m0_37837953/article/details/122762046
Author: 陈明97
Title: TensorFlow2.0 学习-维度
原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/511420/
转载文章受原作者版权保护。转载请注明原作者出处!