KCS: Neural network feed-forward and cost function (ex4)