tf.tile() 用法介绍

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/xwd18280820053/article/details/72867818
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]]




猜你喜欢

转载自blog.csdn.net/xwd18280820053/article/details/72867818
今日推荐