non vectorized implementation of neural network's cost function with regularization
derivative of the sigmoid function