Course 4, Week 2, programming assignment 2 - Transfer Learning with MobileNetV2

I have an issue with Exercise 3:
I have defined:
metrics = tf.keras.metrics.Accuracy(name=“accuracy”)

The following assertion fails:
assert metrics[0] == ‘accuracy’, “Wrong metric”

This assertion doesn’t make sense to me.
I have replaced it by the assertion
assert == ‘accuracy’, “Wrong metric”
which passes but of course that the grader goes with the original assertion.

For metrics, just define the text string - it isn’t a Keras layer.

Be sure you save your notebook before you submit it, and also that you have not modified the file name of the notebook.

When I set
metrics = ‘accuracy’
I get the following error message

AssertionError Traceback (most recent call last)
3 assert type(optimizer) == tf.keras.optimizers.Adam, “This is not an Adam optimizer”
4 assert == base_learning_rate / 10, “Wrong learning rate”
----> 5 assert metrics[0] == ‘accuracy’, “Wrong metric”
7 print(’\033[92mAll tests passed!’)

AssertionError: Wrong metric

Hello, any further input?
It still doesn’t work.

when I follow the advice above and set metrics to be a string
the assertion still fails.

‘accuracy’ should be inside a set of square brackets.

There are examples of this syntax in other cells in the notebook.

Without the square brackets, then “metrics[0]” equals just the letter ‘a’, not the whole word “accuracy”. That’s why the assert fails.

1 Like

Thanks. I should improve my python…