I have a problem in ‘Transfer Leasrning’ assignment with the exersice 3.
I’ve used this metric ‘tf.keras.metrics.Accuracy(name=‘accuracy’)’, but i have problem with assertion, because it says that ‘Accuracy’ object is not subscriptable.
I don’t know what to try next, so I will be very thankful for any help
Hey, you need to pass the accuracy metric in a list as tensorflow expects a list of the metrics in the argument list of compile().
And as it has been used in the previous assignments (and one time before in this assignment as well), you just need to use the string ‘accuracy’ rather than tf.keras.metrics.Accuracy(), as the test checks for the string.
Hey!
Thank you for the answer!
So just to be sure, to call tf.keras.metrics.Accuracy() is equivalent to call [‘accuracy’] but just doesn’t pass the assert test, right?
You’ll have to still put the tf.keras.metrics.Accuracy() in a list so the equivalent statements would be [tf.keras.metrics.Accuracy()] and [‘accuracy’], but yes .
Another fun thing the metrics argument allows is to let you pass your own custom metrics you can build by extending tf.keras.metrics.Metric() and adding that to the metrics list.
So if I made a f1 score custom metric named f_1, I could easily add it by just passing metrics = ['accuracy', f_1] within compile.