简体   繁体   English

将数据帧重塑为 3D

[英]Reshaping a dataframe into 3D

I am trying to reshape an activity recognition dataset into the 3D form to be parsed in 2D CNN.我正在尝试将活动识别数据集重塑为 3D 形式,以便在 2D CNN 中进行解析。 I tried multiple times, but I couldn't figure out how it can be done.我尝试了多次,但我无法弄清楚如何做到这一点。

My Current shape of X_train is (1418, 80, 6), and X_Test is (355, 80, 6).我当前的 X_train 形状是 (1418, 80, 6),而 X_Test 是 (355, 80, 6)。 I am trying to do as follows.我正在尝试执行以下操作。

X_train = X_train.reshape(1418, 20, 2, 1)

And I got the following error:我收到以下错误:

cannot reshape array of size 680640 into shape (1418,20,2,1)

Any advice on how I can reshape the data into 3d so I can pass it in a 2D CNN algorithm?关于如何将数据重塑为 3d 以便我可以在 2D CNN 算法中传递它的任何建议?

Thank you谢谢

By doing:通过做:

X_train = X_train.reshape(1418, 20, 2, 1) on some data that originally has shape (1418, 80, 6) python will output the error: cannot reshape array of size 680640 into shape (1418,20,2,1) X_train = X_train.reshape(1418, 20, 2, 1)在一些原本具有形状(1418, 80, 6)数据上,python 将输出错误: cannot reshape array of size 680640 into shape (1418,20,2,1)

This is happening because you are trying to reshape (80,6) to (20,2,1) 80 * 6 is not equal 20 * 2 * 1.发生这种情况是因为您试图将(80,6)重塑为(20,2,1) 80 * 6 不等于 20 * 2 * 1。

try changing it to something that would result into the same quantity of 80 * 6 such as X_train = X_train.reshape(1418, 40, 12, 1) or X_train = X_train.reshape(1418, 20, 24, 1)尝试将其更改为相同数量的 80 * 6,例如X_train = X_train.reshape(1418, 40, 12, 1)X_train = X_train.reshape(1418, 20, 24, 1)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM