How should I deal with variable input sizes for a neural network classifier?

I am currently working on a project, where I have a sensor in a shoe that records the $$X, Y, Z$$ axes, from an acceleration and gyroscope sensor. Every millisecond, I get 6 data points. Now, the goal is, if I do an action, such a jumping or kicking, I would use the sensor's output to predict that action being done.

The issue: If I jump, for example, one time I may get 1000 data points, but, in another, I get 1200 amounts, meaning the size of the input is different.

The neural networks I've studied so far require the input size to be constant to predict a $$Y$$ value, however, in this case, it isn't. I've done some research on how to make a neural network with variable sizes, but haven't been able to find one which works. It's not a good idea to crop the input to a certain size, because then I am losing data. In addition, if I just resize the smaller trials by putting extra $$0$$s, it skews the model.

Any suggestions on a model that would work or how to better clean the data?

• Welcome to AI.SE. What data in X,Y,Z does it record? Is it position, speed, acceleration, etc? – DuttaA Mar 14 at 17:55
• the accelerometer gives the acceleration in the x,y,z. Then the gyroscope does the same. – Tarun R Mar 14 at 19:46

1 Answer

It is much simpler to process the data in a different way. Since you're using temporal data a common practice is to define a priori a minimum time-step, usually called $$\textit{granularity}$$, which must be bigger than you're sensor responsiveness. Using this granularity value you'll then be able split your data into intervals, and you can then combine each instance belonging to an interval with a function that you like. Most common choice is obviously averaging the values, but also summing then could be a choice or a moving average.

Don't think that in this way you will loose information, preprocessing is also called data cleaning for a reason, not aways raw data are better.

As a last note, I would suggest you to look into 'Machine learning for the quantified self', there is growing literature going on about using sensors to train predictive models about movements and body measures like heart-rate. You might find something about preprocessing for this specific sensor-applications.