I am getting the following error:
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-29-11ffc7a7acb3> in <module>
----> 1 model2 = alpaca_model(IMG_SIZE, data_augmentation)
<ipython-input-28-15ca5ff1e06e> in alpaca_model(image_shape, data_augmentation)
39 # add the new Binary classification layers
40 # use global avg pooling to summarize the info in each channel
---> 41 x = GlobalAveragePooling2D()(x)
42
43 # include dropout with probability of 0.2 to avoid overfitting
NameError: name 'GlobalAveragePooling2D' is not defined
NVM - I see that i need to put the tf.keras stuff in front. ok now
2 Likes
You can read the “import” cell at the beginning to figure out what names are available.
one last problem (hopefully) on the metrics (I am assigning tf.keras.metrics.Accuracy to metrics):
TypeError Traceback (most recent call last)
<ipython-input-47-2a3573945f89> in <module>
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
But you can see from the assertion that is not what they are expecting, right? The first rule of debugging is “Believe the error message”.
They gave you an example of how to write that code earlier in the notebook.
Yes, I see now. I was using the tf.keras stuff so often that I assumed it had to be one of them. I didn’t notice the earlier reference - it was a bit subtle I have to say.