np.tile() 重复生成数组

np.tile(a,n)

功能是将a(a可以不是数组)重复n次,构成一个新的数组,n可以是int,或者是tuple

1.n是int

from numpy import *
a=[0,1,2]
tile(a,2)
#array([0, 1, 2, 0, 1, 2])

2.n是tuple(i,j)

反正就是把a作为一个整体,行重复i此,列重复j次

from numpy import *
a=[0,1,2]
tile(a,(2,2))

'''
array([[0, 1, 2, 0, 1, 2],
       [0, 1, 2, 0, 1, 2]])
'''
原文地址:https://www.cnblogs.com/cgmcoding/p/13614071.html