Fix mlp softmax misclass and cost_from_X when the top layer is Softmax with binary_target_dim

This is a rebase of  #1195