创建三维数组A第一页为第二页为第三页为然后用reshape 函数重排为数组BB 为3 行、2 列、2 页。给出程序语句。
import numpy as np
# 创建三维数组A
A = np.array([[[1, 2], [3, 4]], [[5, 6], [7, 8]], [[9, 10], [11, 12]]])
# 重排为数组B
B = np.reshape(A, (3, 2, 2))
print(B)
输出:
array([[[ 1, 2],
[ 3, 4]],
[[ 5, 6],
[ 7, 8]],
[[ 9, 10],
[11, 12]]])
原文地址: https://www.cveoy.top/t/topic/fH6D 著作权归作者所有。请勿转载和采集!