# How to use Neural Network classification if data not same size?

I have data like this.

[0 1 0 1 0]
[0 1 0 1 0 1 1]
[0 1 0 1 ]
[0 1 0 1 0 1 1 1 1 0]
...


I want to classify with Neural Network but my data different size . I can not delete or add more arbitaly data. It may make the result not correct. So, How to classification data different size ?

• Welcome to CS.SE! We probably can't answer this question in isolation, without context. Can you edit your question to provide additional context? What is the meaning of the features? What kind of data are you working with? What is the meaning of the classes, and how do they relate to the features? Normally, standard neural networks require all feature vectors to be the length. Have you tried thinking about whether you can devise any features that will satisfy that? – D.W. May 19 '17 at 15:10
• Your classifier can (and very likely will) make mistakes regardless of the representation of the data. – Juho Nov 15 '17 at 14:40

I can not delete or add more arbitaly data. It may make the result not correct.

Don't make assumptions about neural networks. They can map any function, and if you don't add more data (padding) then you can't even train your network in the first place.

If your data consists of merely 0's and 1's. You could either do the following:

• pad all blanks with 0.5 ([0 1 0 1 0, 0.5, 0.5, 0.5, .0.5]), however the neural network will think that 0.5 is as far from 1 as it is from 0.
• pad all blanks with 0.5 (this is what I recommend), if your data is binary (e.g. true/false), then all false must be set to 0 consistently. 0 then has the double meaning: false or not present.

There is no other option besides adding 'blank' data, if you don't add data, the network will still see this as a 0.

But you should try before you ask. "It may make the result not correct." is not a good argument to not do something. Your data doesn't seem that big, so you can easily test through trial and error.

• "There is no other option besides adding 'blank' data". This is wrong. For a counter example, if the data were images of a strip of a barcode (which should have physical size, but was taken by camera at varying distance), it clearly make more sense to scale rather than pad the data. To sum it up, It depends on the nature of data. – Billiska May 19 '17 at 12:56
• @Billiska that would require preprocessing of input data. If the data were images of a strip of a barcode, and the neural networks task is to classify the barcode in an image, then what is the point of the neural network if you are going to preprocess it anyway. Padding with 0's is a fairly common thing to do for neural networks, especially for convolutional networks like you described (adeshpande3.github.io/…) – Thomas W May 19 '17 at 13:02
• common doesn't imply correct. Some of points in preprocessing are to (1) train faster, (2) get more accuracy. Sure given enough network structure and training time, NN can probably figure out whether to pad or scale or something else. But that is slower and uncertain. – Billiska May 19 '17 at 13:25
• @Billiska you dont even know if it would be better to preprocess, because the OP hasnt even given a clue on what type of data he is processing. As they are only small arrays, im 80% certain that you cant scale his samples down like you proposed. But OP is too vague to give a specific answer. – Thomas W May 19 '17 at 13:33
• I did not propose to scale. I did say it's not right to simply conclude you can only pad. Reason is exactly as you said, not enough information. If there was enough information, I would write another answer rather than commenting. – Billiska May 19 '17 at 14:29

I'm not an expert, but my understanding is the Recurrent Neural Networks are well suited to deal with sequences of data. This article gives a good (but possibly sensationalized) overview.