A Variational Approach to Learning Curves