implemented binarization output function, cost function is part of training