Python中三维变二维矩阵(用reshape)后各个维度的关系

版权声明:请征得博主同意后,再进行转载 https://blog.csdn.net/qq_34840129/article/details/86467817

将一个5X40的二维矩阵变为一个5X20X2的三维数据。

import numpy as np
X_test = np.arange(100).reshape(5,20)

print(X_test)
X_test = X_test.reshape([X_test.shape[0], 10, 2])

得到的三维的X_test是5个二维的二维矩阵叠加而成的。

第一个二维矩阵为:X_test = [0, :, :]            第二个二维矩阵为:X_test = [1, :, :]                      

                                                

第三个二维矩阵为:X_test = [2, :, :]            第四个二维矩阵为:X_test = [3, :, :]

                                                 

第五个二维矩阵为:X_test = [2, :, :] 

猜你喜欢

转载自blog.csdn.net/qq_34840129/article/details/86467817
今日推荐