简体   繁体   中英

Reshaping a dataframe into 3D

I am trying to reshape an activity recognition dataset into the 3D form to be parsed in 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). 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?

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)

This is happening because you are trying to reshape (80,6) to (20,2,1) 80 * 6 is not equal 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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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