I want to classify 8 noisy signals with trainNetwork() function that is available in Matlab. All Matlab examples were for image classification. The arguments are the data and its label, the CNN layers, in which the first layer is imageInputLayer([32 32 3]). My question is can this function be used to classify 1-D signals? if yes, how can we create such a layer?

  • $\begingroup$ You have 8 instances? Like 8 examples? $\endgroup$
    – JahKnows
    Apr 20, 2017 at 18:04
  • $\begingroup$ That's true. I have 8 classes, each one is a signal of 256 samples. I have created a dataset the contains 80000 signals from these 8 signals (classes). So, the problem is to classify 1D signals of [256,80000] into 8 classes. $\endgroup$
    – Husam
    Apr 22, 2017 at 9:55

1 Answer 1


A CNN usually requires a lot of data. And of course even more data if you have a very large feature set. And even more data if you have many output classes. The number of output classes makes the necessary amount of data samples to increase exponentially.

The most important part of any machine learning project is to extract the most telling features from your raw data. Ask yourself in your signal what are the telltale signs that should tell your model what class the signal was drawn from.

You should try to use some feature extraction techniques, then you should try to use a model better suited for the size of your dataset.

Data pre-processing and feature extraction

Data pre-processing goes from your raw data and remolds it to be better suited to machine learning algorithms. This means pulling out important statistics from your data or converting your data into other formats in order to it being more representative. For example if you are using a technique which is sensitive to range, then you should normalize all your features. n your case if you have a signal you might want to extract some information about the temporal and frequency domain transforms. You can try something like empirical mode decomposition (EMD).

Then, you want to use feature selection. From all the information you extracted from your data not all of it will be useful. There are machine learning algorithms such as: PCA, LDA, cross-correlation, etc. Which will select the features that are the most representative and ignore the rest.

In your case

As a general rule of thumb, the amount of data that I suggest to have for shallow machine learning models is $10 \times \#features$. For deep models I usually suggest $100 \times \#features \times \#outputs$. So you are limited by the size of your dataset. In your case a CNN is not recommended. Only recently a group published a quite controversial result of training a CNN with 100,000 examples. The community generally believes that this is way too little and it is not feasible to expect good results when training a CNN with very little data.

The Model

I suggest you use a general machine learning technique such as SVM. This will likely result in better result. Try these techniques instead and see what results you get: k-NN, kernel SVM, k-means clustering.

  • $\begingroup$ Although maybe the OP does not need a deep NN, I think this answer is too pessimistic about the prospects. The MNIST digits dataset has 70,000 samples, each of which has 784 features and 10 classes (slightly worse values than the OP's problem in all areas according to your recommendations). The state-of-the-art solutions to MNIST digits are all deep neural networks. SVM models - without manual feature extraction - do badly on MNIST in comparison. I would encourage the OP to still explore a CNN-based model with the description as it stands. $\endgroup$ May 11, 2017 at 7:03
  • $\begingroup$ If you look at the MNIST results using deep networks they generate artificial examples to supplement their sample size and increase variability in the samples. For example they introduce transformations and noise or distortions in the network and the image samples. Also, MNIST is not a good benchmark. It is far too easy of a dataset. You can get very good results using K-means or even simple kernel trick and any linear separator. Try it and you'll achieve results >90% with the easiest methods and no preprocessing. $\endgroup$
    – JahKnows
    May 11, 2017 at 14:57
  • $\begingroup$ By all means you can always attempt to use deep learning and try to brute force your way to a solution. However, if the need is not there then why pursue it. I always suggest to go from the ground up, start with feature extraction and try statistical methods in order to determine if your features are valuable. From there you can try some machine learning algorithms and if you see that your problem is well suited for deep learning then go for it. Having terrible features going into a CNN is an abuse of power. $\endgroup$
    – JahKnows
    May 11, 2017 at 15:01
  • $\begingroup$ You can get 99% accuracy in MNIST test with no data augmentation, just training the scaled data on a basic CNN. I have done so, and there are many examples of this available online. Agreed it is a simple data set, and it does play to CNN strengths - but then so do a lot of signal processing tasks, such as speech recognition. The OP also has a signal processing task - the features could well be locally correlated. $\endgroup$ May 11, 2017 at 15:16
  • $\begingroup$ I'm not disagreeing with no data augmentation and a 6-layered CNN I got 99.6% highest I have until now. However, why beat your data to death like that. There is no harm in trying it. However, if you are pressed for time as is usually the case in academia or in the workplace you need to know how to select your models efficiently to play to the strengths of your dataset. I do not suggest applying CNNs blindly. You must understand that more introduced variables will increase the bias in your network. Is your data noisy which will increase the bias? Do you have enough data to reduce that bias? $\endgroup$
    – JahKnows
    May 11, 2017 at 15:24

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.