创建2页,3行,4列的三维矩阵
import numpy as np
t = np.random.random((2,3,4))
print(t)
[[[0.18589574 0.5723089 0.38505554 0.14135623]
[0.73036206 0.58540968 0.57741716 0.02551514]
[0.86965835 0.54080129 0.80261298 0.37144176]]
[[0.83052614 0.83502562 0.47811981 0.723045 ]
[0.33586194 0.39660702 0.58520309 0.15943745]
[0.32893033 0.40983408 0.10889919 0.64272805]]]
提取第1页的二维矩阵(python的索引是从0开始)
print(t[1])
[[0.83052614 0.83502562 0.47811981 0.723045 ]
[0.33586194 0.39660702 0.58520309 0.15943745]
[0.32893033 0.40983408 0.10889919 0.64272805]]
按页方向求取平均值。行方向为axis=1,列方向axis=2
a = np.mean(t,0)
[[0.50821094 0.70366726 0.43158768 0.43220061]
[0.533112 0.49100835 0.58131013 0.0924763 ]
[0.59929434 0.47531768 0.45575608 0.50708491]]
提取第0页,第1行,第2列的数值
b = t[0][1][2]
print(b)
0.57741716