np.repeat() 用法
1.单词repeat:重复相关的词义2.使用np.repeat(1, 5)array([1, 1, 1, 1, 1])# 1 重复5次x = np.array([[1,2],[3,4]])np.repeat(x, 2)array([1, 1, 2, 2, 3, 3, 4, 4])# 合并维度np.repeat(x, 3, axis=1)array([[1, 1, 1, 2, 2, 2],[3, 3
·
1.单词
repeat:重复相关的词义
2.使用
np.repeat(1, 5)
array([1, 1, 1, 1, 1])
# 1 重复5次
x = np.array([[1,2],[3,4]])
np.repeat(x, 2)
array([1, 1, 2, 2, 3, 3, 4, 4])
# 合并维度
np.repeat(x, 3, axis=1)
array([[1, 1, 1, 2, 2, 2],
[3, 3, 3, 4, 4, 4]])
# 将重复操作施加到 维度‘axis=1’上,相当于‘增加列数’
np.repeat(x, [1, 2], axis=0)
array(
[[1, 2],
[3, 4],
[3, 4]]
)
# 将重复操作施加到 维度‘axis=0’上,相当于‘增加行数’,重复的次数,分别为一次和两次
更多推荐
已为社区贡献1条内容
所有评论(0)