以上三個函數,主要區別在于能夠拓展維度上和重復方式:
- np.tile() 能夠拓展維度,并且整體重復:
1 a = np.array([0,1,2]) 2 np.tile(a,(2,2)) 3 # out 4 # array([[0, 1, 2, 0, 1, 2], 5 [0, 1, 2, 0, 1, 2]])
2. np.repeat()能夠將多維flatten一維后,進行個體重復:
1 b = np.array([[1,2,3],[4,5,6]]) 2 np.repeat(b,3) 3 # out 4 #array([1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6])
3. tf.tile()不能拓展維度,若要實現維度推展,請搭配tf.expand_dims食用。效果也是整體重復。
![]()

浙公網安備 33010602011771號