# Are CNNs insensitive to rotations and shifts in images?

Can CNNs predict well if they are trained on canonical-like images but tested on a version of images that are little bit shifted?

I tried it using mnist dataset and found the contrary. The accuracy of the test set that was shifted was very low as compared to MLPs.

If you use max-pooling layers, they may be insensetive to small shifts but not that much. If you want your network to be able to be invariant to transformations, such as translations and shifts or other types of customary transformations, you have two solutions, at least as far as I know:

• Increasing the size of data-set
• Using spatial transformers

Thanks to one of our friends, another way is to use transfer learning after data-augmentation.

• Aha by doing data augmentation. and training on augmented data – Boris Mar 25 '18 at 10:50
• @Boris yes, you can augment your data by adding appropriate transformations. Your network will perform in a way that the data is. – Media Mar 25 '18 at 10:51
• But in Lenet-5 it was not trained on augmented data,but it still worked perfect and gave high accuracy\ – Boris Mar 25 '18 at 10:57
• @Boris: I think it would help you to understand more about the issues with modifications in CNNs. E.g. positional invariance (changes in location) are a different story than equivariance (changes in scale / orientation). Pooling layers bring some positional invariance but come with a catch: They also lose the location of features leading to false positives. Caps nets might bring a solution and explain the issue well. There are a bit difficult post (hackernoon.com/…) and paper (arxiv.org/abs/1710.09829) about it. – Gegenwind Mar 25 '18 at 11:09
• @Boris capsnetsare supposed to address position, size, orientation and more, so they can improve on both aspects. They are able to differentiate how to pass on features to further layers instead of following just the strongest signals. For more details I can only refer to the paper because my understanding of caps nets is quite limited. It also is a rather young research topic so you might need to do some pioneering if you want to work on those. – Gegenwind Mar 25 '18 at 18:56

Convolution is shift-equivariant except for border effects. Fully connected layers aren't.

Pooling (without subsampling/stride) can be seen as a kind of smoothing, and its output is often the same for many neighboring positions. Subsampling this (applying a stride) results in an operation that is fairly invariant to small shifts.

Global pooling is fully shift invariant, again except for border effects.

As for rotations: standard architectures aren't inherently robust to those.

Try MS COCO dataset: it is VERY diverse, and try training the network for detection/segmentation. The best-performing networks like Mask R-CNN produce about 44% mAP on test data or 68% at 0.5 IoU. It handles all challenges, including rotation fairly well, but is quite hard to train.