Implemented the regularized version of the NN cost function