tf.tile()

tile() 平铺之意,用于在同一维度上的复制

tile(
    input,     #输入
    multiples,  #同一维度上复制的次数
    name=None
)

 

with tf.Graph().as_default():
    a = tf.constant([1,2],name='a') 
    b = tf.tile(a,[3])
    sess = tf.Session()
    print(sess.run(b))
对[1,2]的同一维度上复制3次,multiples参数维度与input维度应一致, 结果如下:
[1 2 1 2 1 2]
with tf.Graph().as_default():
    a = tf.constant([[1,2],[3,4]],name='a')   
    b = tf.tile(a,[2,3])
    sess = tf.Session()
    print(sess.run(b))
输出:
[[1 2 1 2 1 2]
 [3 4 3 4 3 4]
 [1 2 1 2 1 2]
 [3 4 3 4 3 4]]

 

posted @ 2022-08-16 08:41  Tomorrow1126  阅读(29)  评论(0编辑  收藏  举报