Fix logistic regression gradient and cost