Implemented regularized cost function for neural network