I seem to have a problem modelling my CNN network.

I want to extract from features vector from different sized images. Whats consistent with the images is the y-axis, and the color dimension, but the x-axis is not constant.

Depending on the length of the x-axis will the length of the feature vector also be altered. I already know how long they should be, but not the ratio between the length of the x-axis and length of the feature vector, I guess one does exist.

Is it possible to train a CNN network such that it can alter the feature vector length depending on the length of the input of the x-axis of the image?

| improve this question | | | | |
  • $\begingroup$ Why not resize your images into the same shape? $\endgroup$ – Icyblade Mar 8 '17 at 2:30
  • $\begingroup$ Sometimes a need a feature vector of length A or length B.. Shaping it to the same size would not let me alter the length of the feature vector.. So resizing the image, would do any good here? $\endgroup$ – Carlton Banks Mar 8 '17 at 2:54

It is not really possible to alter input feature array size per example on normal CNNs. Instead this is fixed when the model is built for the first time, before you start training.

Depending on your goal, it might be possible to work around that using some kind of pipeline that worked with image patches (taking multiple slightly randomised patches to augment the training data can improve results and doing the same with prediction inputs can also drive up classifier accuracy). Or a more complex variant using RNN/CNN hybrid to consume an image as a sequence of parts, which might also be used for multi-object recognition.

However, these solutions are complex, and state-of-the-art results in image classification can be achieved by simpler techniques such as taking a centre crop and/or padding. Provided your training data is also treated the same way, and aspect ratios are not extreme this can work adequately.

| improve this answer | | | | |
  • $\begingroup$ Guess I have to find the ratio and work it out that way. $\endgroup$ – Carlton Banks Mar 8 '17 at 11:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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