Update NeuralNetwork

Added optimize function directly to NN class