<p>I am working on building a model to classify the type of touch the user makes(Long Press, Left Swipe, Right swipe and so on). I have data with features that characterise the user's touch, like duration, velocity in x-direction, velocity in y-direction etc. One feature that's also present is the <strong>trajectory</strong> of the touch.</p>
<p>The problem is that for touches like taps or long-press, the length of the trajectory array is 2 or 3 points, but for swipes, it reaches up to 40-100 points. What I thought can work is either use padding or use CNNs. But the problem with padding is that as I am using trajectories, if I pad them with 0s it might affect the learning because a '0' still has meaning in trajectories as some points. And what I think the problem might be with CNNs is that first I don't know if such  an architecture could work for <strong>all features</strong> (touch duration, xVelocity etc.) as they are not spatially related. I may be wrong about this, feel free to correct it. I also thought of using RNNs but I did not as they are mainly used for NLP tasks and all the features are not related to each other sequentially.</p>
<p>What are the different ways I can handle this kind of variable-sized input feature for neural networks?</p>

CC BY-SA 4.0
2021-08-10T16:04:24.977Z
"all the features are not related to each other sequentially." - what? Trajectory points **are** related to each other sequentially!
Criticize SE actions means ban
CC BY-SA 4.0
2021-08-10T17:35:29.433Z
yeah but as I mentioned, they are just one feature of the model, others include touchDuration, x-velocity, y-velocity etc and so they are not sequentially related to the trajectory right? That's why I made the 'all features' bold
Ravish Jha
<neural-networks><machine-learning><deep-learning><convolutional-neural-networks><feature-engineering>
How to pass variable length data as feature to a neural network?
Ravish Jha
# How to pass variable length data as feature to a neural network?

(Asked by: username_0 on 2021-08-10)

I am working on building a model to classify the type of touch the user makes(Long Press, Left Swipe, Right swipe and so on). I have data with features that characterise the user's touch, like duration, velocity in x-direction, velocity in y-direction etc. One feature that's also present is the **trajectory** of the touch.

The problem is that for touches like taps or long-press, the length of the trajectory array is 2 or 3 points, but for swipes, it reaches up to 40-100 points. What I thought can work is either use padding or use CNNs. But the problem with padding is that as I am using trajectories, if I pad them with 0s it might affect the learning because a '0' still has meaning in trajectories as some points. And what I think the problem might be with CNNs is that first I don't know if such an architecture could work for **all features** (touch duration, xVelocity etc.) as they are not spatially related. I may be wrong about this, feel free to correct it. I also thought of using RNNs but I did not as they are mainly used for NLP tasks and all the features are not related to each other sequentially.

What are the different ways I can handle this kind of variable-sized input feature for neural networks?

**Tags:** neural-networks, machine-learning, deep-learning, convolutional-neural-networks, feature-engineering

> **Comments:**
> **username_1**: "all the features are not related to each other sequentially." - what? Trajectory points **are** related to each other sequentially!  
> **username_0**: yeah but as I mentioned, they are just one feature of the model, others include touchDuration, x-velocity, y-velocity etc and so they are not sequentially related to the trajectory right? That's why I made the 'all features' bold  

---

## 0 answers

