Skip to content
Advertisement

Reshape Python List to Match Input Layer (Data preprocessing – Keras – LSTM – MoCap)

Good Day,

I am trying to train LSTM using multiple excel files (Motion Capture Data) as input. Each excel file represents a body motion, I would like to train the network using multiple motions in the training set and in the tests set. Below the example of a single excel file:

Input Sample

As for the input shape, it’s (1, 2751, 93), the input dimension breakdown: samples: 1, time steps: 2751, features: 93

The input independent variable (x) is the human joints along with their positions, and the dependent (y) is the labels of each movement.

Thanks in Advance!

EDIT: Added Elaborate Code

JavaScript

The output:

Output Sample

Whereby, the expected output to get when invoking the ‘df.head()’ is something similar to this output: enter image description here

What I am trying to do is to be able to get/print every record (row) separately when desired. I was able to do that when loading a single dataframe using the below sample code, but failed when tried to load multiple dataframes into a list then trying to implement the same step for each dataframe using a loop.

JavaScript

EDIT: Question Clarified!

Simply, what do I have now is the following:

  1. 8 dataframes stored in a list (list shape (8,))
  2. Each dataframe shape is (300,93)

what do I want to do is have this list shaped to (8, 300, 93) for instance so it matches the input layer for the neural network.

As I keep getting the below error:

JavaScript

I am requesting clarification if possible as things are sort of vague at my end as to why I am having this error.

Thanks in-advance!

Advertisement

Answer

Wrote this function to handle the preprocessing to overcome the reshaping issue. Also, the function encodes the labels (y) using Scikit-Learn ‘LabelEncadoer()’.

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement