I'm building an application for Android devices that requires it to recognize, by accelerometer data, the difference between walking noise and double tapping it. I'm trying to solve this problem using Neural Networks.

At the start it went pretty well, teaching it to recognize the taps from noise such as standing up/ sitting down and walking around at a slower pace. But when it came to normal walking it never seemed to learn even though I fed it with a large proportion of noise data.

My question: Are there any serious flaws in my approach? Is the problem based on lack of data?

The network

I've choosen a 25 input 1 output multi-layer perceptron, which I am training with backpropagation. The input is the changes in acceleration every 20ms and output ranges from -1 (for no-tap) to 1 (for tap). I've tried pretty much every constallation of hidden inputs there are, but had most luck with 3 - 10.

I'm using Neuroph's easyNeurons for the training and exporting to Java.

The data

My total training data is about 50 pieces double taps and about 3k noise. But I've also tried to train it with proportional amounts of noise to double taps.

The data looks like this (ranges from +10 to -10):

Sitting double taps: https://i.stack.imgur.com/a7PDT.png

Fast walking: https://i.stack.imgur.com/ljRwp.png

So to reiterate my questions: Are there any serious flaws in my approach here? Do I need more data for it to recognize the difference between walking and double tapping? Any other tips?

  • $\begingroup$ Hi, so were you able to solve your problem? $\endgroup$ Nov 14, 2015 at 0:58

1 Answer 1


Based on your post I'm assuming you haven't had much experience with this type of work. Here are several things that immediately jump out as being potential problems:

  • You should probably perform some type of preprocessing so your inputs are in a more acceptable range such as (-1, 1), or (0, 1). When the magnitude of the input values are large, the the hidden units are likely to saturate (i.e. be very close to $\pm$ 1 assuming you're using tanh hidden units). This causes the gradients to be nearly zero which can result in backpropagation performing poorly.

  • In my experience, you will not get good results when you have very unbalanced classes (50 tap, 3000 no tap) if you just naively apply some machine learning algorithm. For example, a classifier which always outputs -1 will achieve approximately 98% accuracy on your dataset, while being completely useless for your task.

  • Since you have not mentioned a training/test split of your dataset or cross validation, I'm assuming you're not doing these things. You should be. Neural networks are notorious for overfitting and if you use the same data to train and assess accuracy, you almost surely will.

That being said, I'm surprised this question hasn't been closed or migrated. It is almost certainly a better match for the CS stack exchange or Metaoptimize.

  • $\begingroup$ Hi, thanks for your answer. The data I posted is normalized between -1 and 1. We are doing cross validation now and are seeing better results compared to the amount of data. I'm curious thought - do you think that a set of maybe 100 taps and noise data would be sufficient or way to low? $\endgroup$ Jun 25, 2012 at 6:29
  • $\begingroup$ That's good to hear that cross validation helped. Unfortunately, getting ML algorithms to work in the world is more art than science, and involves a lot of guess and check work in my experience. That doesn't mean you shouldn't be scientific about it. Have a look at these slides from Andrew Ng. They do good job of introducing some common ML diagnostics. $\endgroup$
    – alto
    Jun 25, 2012 at 12:36
  • $\begingroup$ "...more art than science..." I think I'm starting to realize that. Great link. $\endgroup$ Jun 25, 2012 at 14:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.