I was reading about Logistic Regression and trying to implement the model from scratch. Maybe I am wrong, but I have noticed that the loss calculation step is meaningless in training a Logistic Regression model.

For example:

loss = -(y * np.log(y_hat) + (1 - y) * np.log(1 - y_hat))

Almost every article or video I have watched it was said that "We need calculate the loss based n output and the ground truth values". But then when we do backprop through the model we calculate gradient for dz like this:

dz = y_hat - y

And parameters are calculated like this:

dw = np.dot(x, dz.T) / m
db = np.sum(dz) / m

Gradient descent:

w = w - learning_rate * dw
b = b - learning_rate * db

Through all of these steps there is not a single place where the variable loss was used. From what I can conclude is that we are calculating loss just to print it on the screen for the programmer to see how is the training process going (to see if the model is learning something or not).

Does that mean that the loss calculation step is not needed at all or am I missing some key points?

If answer t the previous question is NO, does that mean that loss calculation step is trivial in Neural Networks as well?



You must log in to answer this question.

Browse other questions tagged .