Factored ou the cost code for softmax