numpy 三维矩阵
时间: 2023-12-14 13:33:00 浏览: 199
python 二维矩阵转三维矩阵示例
5星 · 资源好评率100%
以下是一个关于numpy三维矩阵的例子:
```python
import numpy as np
# 生成一个三维矩阵,五堆,五行,两列
a3d = np.arange(50).reshape(5, 5, 2)
print(a3d)
```
输出结果为:
```
array([[[ 0, 1],
[ 2, 3],
[ 4, 5],
[ 6, 7],
[ 8, 9]],
[[10, 11],
[12, 13],
[14, 15],
[16, 17],
[18, 19]],
[[20, 21],
[22, 23],
[24, 25],
[26, 27],
[28, 29]],
[[30, 31],
[32, 33],
[34, 35],
[36, 37],
[38, 39]],
[[40, 41],
[42, 43],
[44, 45],
[46, 47],
[48, 49]]])
```
阅读全文