neural network cost fcn and its tests