improved gradient descent in NeuralNetwork

Added automatic convergence testing and support for learning rate decay to stochastic gradient descent, and did some general clean up in the NeuralNetwork class.