On the geometry of generalization and memorization in deep neural networks