added cost function for neural network