Learning How to Generalize