The assertion block for the fine-tuning model is throwing an error for the accuracy object NOT being subscriptable. If the object is not subscriptable and the assertion block throws an error if it is NOT then either the tf.keras.metric.Accuracy() method is not outputting the wrong type of object or the assertion block to check code is incorrect. Which is it?
ASSERTION BLOCK
assert type(loss_function) == tf.python.keras.losses.BinaryCrossentropy, “Not the correct layer”
assert loss_function.from_logits, “Use from_logits=True”
assert type(optimizer) == tf.keras.optimizers.Adam, “This is not an Adam optimizer”
assert optimizer.lr == base_learning_rate / 10, “Wrong learning rate”
assert metrics[0] == ‘accuracy’, “Wrong metric”
print(‘\033[92mAll tests passed!’)
ERRORS
TypeError Traceback (most recent call last)
in
3 assert type(optimizer) == tf.keras.optimizers.Adam, “This is not an Adam optimizer”
4 assert optimizer.lr == base_learning_rate / 10, “Wrong learning rate”
----> 5 assert metrics[0] == ‘accuracy’, “Wrong metric”
6
7 print(‘\033[92mAll tests passed!’)
TypeError: ‘Accuracy’ object is not subscriptable