A Theory of Deep Learning