Added regularization to neural network gradients