以上三个函数,主要区别在于能够拓展维度上和重复方式:

  1.   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])
View Code

  3.  tf.tile()不能拓展维度,若要实现维度推展,请搭配tf.expand_dims食用。效果也是整体重复。

  

  

 

posted on 2019-06-03 09:28  无邪丫丫  阅读(438)  评论(0编辑  收藏  举报