Several problems with compute_cost in assignment

The following has several problems.

  1. A2 but documentation says A
  2. this should return logloss not cost
  3. cost is described as “percentage of incorrectly identified classes” while the expected value is less than 1 (and is equal to the logloss)

def compute_cost(A2, Y):
“”"
Computes the cost function as a log loss

Arguments:
A -- The output of the neural network of shape (1, number of examples)
Y -- "true" labels vector of shape (1, number of examples)

Returns:
cost -- percentage of incorrectly identified classes

"""
# Number of examples.
m = Y.shape[1]

### START CODE HERE ### (~ 2 lines of code)
logloss = None
cost = None
### END CODE HERE ###

Hi @toontalk!

I will inform our Curriculum Engineer to fix the A2 in the code. Thanks!

Regarding 2. and 3., I think there is a misunderstanding between the cost and the log-loss. The log-loss is computed just for a single point in the training set, regarding how “far” a point is to be classified correctly whereas the cost is the (negative) mean of the log-loss for each classified point in the training dataset, and describes overall how the estimator is performing. The negative sign is just for optimization purposes.

I hope that helps.

Thanks,
Lucas

The exercise says

Returns:
cost – percentage of incorrectly identified classes

Your description " the cost is the (negative) mean of the log-loss for each classified point in the training dataset" is much better.

You are correct, the explanation for the cost function is not properly written. Thanks for spotting this! It should be fixed soon.

Lucas