A Principle of Least Action for the Training of Neural Networks