On the Benefits of Invariance in Neural Networks