ANN cost function without gradient