get shape of numpy array
AI 回答
由 glm-4-flash 生成 · 仅供参考,请自行核实
1. 使用 `numpy.array.shape` 获取形状。
2. 使用 `numpy.shape()` 函数,传入数组作为参数。
3. 如果数组是二维的,形状为 `(rows, columns)`。
4. 如果数组是多维的,形状为 `(dim1, dim2, ..., dimN)`。
示例代码:
import numpy as np
arr = np.array([[1, 2, 3], [4, 5, 6]])
shape = np.shape(arr)
print(shape) # 输出: (2, 3)
2. 使用 `numpy.shape()` 函数,传入数组作为参数。
3. 如果数组是二维的,形状为 `(rows, columns)`。
4. 如果数组是多维的,形状为 `(dim1, dim2, ..., dimN)`。
示例代码:
import numpy as np
arr = np.array([[1, 2, 3], [4, 5, 6]])
shape = np.shape(arr)
print(shape) # 输出: (2, 3)
没有找到「get shape of numpy array」相关的内容
建议:检查关键词是否有错别字,或换一个更常见的说法。