numpy shape方法的使用
import numpy as np
group = np.array([[1.0, 1.1], [1.0, 1.0], [0, 0], [0, 0.1]])
print(group.shape) # (4,2)
print("行大小 " + str(group.shape[0]))
print("列大小 " + str(group.shape[1]))numpy tile方法使用
tile(A, B)
np.tile([1,1], (4, 1)) 在行方向上重复4次,列方向上重复一次。表示如下
>>> np.tile([1,1], (4, 1))
array([[1, 1],
[1, 1],
[1, 1],
[1, 1]])
>>> np.tile([1,1], (4, 2))
array([[1, 1, 1, 1],
[1, 1, 1, 1],
[1, 1, 1, 1],
[1, 1, 1, 1]])
在行方向上重复4次,列方向上重复1次
本文介绍NumPy中数组的shape属性用法,展示如何获取数组的维度信息,并通过实例说明了tile方法如何沿不同轴重复数组内容。
18万+

被折叠的 条评论
为什么被折叠?



