[英]Cloning row in numpy.tile
This answer https://stackoverflow.com/a/1582742/13326667 has details on cloning row using numpy.tile.这个答案https://stackoverflow.com/a/1582742/13326667详细介绍了使用 numpy.tile 克隆行。
>>> tile(array([1,2,3]), (3, 1))
array([[1, 2, 3],
[1, 2, 3],
[1, 2, 3]])
What is the purpose of (3,1)
here? (3,1)
这里的目的是什么? Can someone explain what the 3
means and the 1
means?有人能解释一下3
和1
是什么意思吗?
3
is the number of times he have to clone it horizontally 3
是他必须水平克隆它的次数
and 1
is the number of times he have to clone it vertically: 1
是他必须垂直克隆它的次数:
for example if you have:例如,如果您有:
import numpy as np
tile = np.tile(
np.array([
[1,2,3], #<- row 1 here
[1,2,3] #<- row 2 here
]),(2,2)
)
print(tile)
you would get the array, cloned 2 times vertically and 2 times horizontally:你会得到数组,垂直克隆 2 次,水平克隆 2 次:
[[1 2 3 1 2 3]
[1 2 3 1 2 3]
[1 2 3 1 2 3]
[1 2 3 1 2 3]]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.