numpy.repeat(a, repeats, axis=None)
>>> a = np.arange(3) >>> a array([0, 1, 2]) >>> np.repeat(a, 2) array([0, 0, 1, 1, 2, 2]) >>> a = np.array([[1,2],[3,4]])>>> aarray([[1, 2], [3, 4]])>>> np.repeat(a, 2, 1)array([[1, 1, 2, 2], [3, 3, 4, 4]]) >>> np.repeat(a, 2, 0)array([[1, 2], [1, 2], [3, 4], [3, 4]])
tile函数功能:对整个数组进行复制拼接
>>> a array([[1, 2], [3, 4]]) >>> np.tile(a, 2) array([[1, 2, 1, 2], [3, 4, 3, 4]])
原文地址:https://www.cnblogs.com/573177885qq/p/10320405.html
时间: 2024-11-09 10:22:53