np.tile
Python numpy 下的 np.tile有些类似于 matlab 中的 repmat函数。不需要 axis 关键字参数,仅通过第二个参数便可指定在各个轴上的复制倍数。
>> a = np.arange(3)
>> np.tile(a, 2)
array([0, 1, 2, 0, 1, 2])
>> np.tile(a, (2, 2))
array([[0, 1, 2, 0, 1, 2],
[0, 1, 2, 0, 1, 2]])
>> b = np.arange(1, 5).reshape(2, 2)
>> np.tile(b, 2)
array([[1, 2, 1, 2],
[3, 4, 3, 4]])
# 等价于
>> np.tile(b, (1, 2))
01-24
11万+
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交