Hey there,
In DLS course 4, week-2, in programming assignment: transfer learning with MobileNet, when I tried to add Add the new Binary classification layers, the following error raised. Could someone correct me over this? Thanks
# Add the new Binary classification layers
# use global avg pooling to summarize the info in each channel
x = tfl.GlobalAveragePooling2D()(x)
#include dropout with probability of 0.2 to avoid overfitting
x = tfl.Dropout(0.2)(x)
# create a prediction layer with one neuron (as a classifier only needs one)
prediction_layer=tfl.Dense(units=1, activation='sigmoid')
### END CODE HERE
outputs = prediction_layer(x)
model = tf.keras.Model(inputs, outputs)
Error message:
AttributeError Traceback (most recent call last)
in
10 [‘Dense’, (None, 1), 1281, ‘linear’]] #linear is the default activation
11
—> 12 comparator(summary(model2), alpaca_summary)
13
14 for layer in summary(model2):
~/work/W2A2/test_utils.py in summary(model)
29 result =
30 for layer in model.layers:
—> 31 descriptors = [layer.class.name, layer.output_shape, layer.count_params()]
32 if (type(layer) == Conv2D):
33 descriptors.append(layer.padding)
/opt/conda/lib/python3.7/site-packages/tensorflow/python/keras/engine/functional.py in output_shape(self)
285 RuntimeError: if called in Eager mode.
286 “”"
→ 287 return nest.map_structure(backend.int_shape, self.output)
288
289 def _set_output_names(self):
/opt/conda/lib/python3.7/site-packages/tensorflow/python/keras/engine/functional.py in output(self)
268 RuntimeError: if called in Eager mode.
269 “”"
→ 270 return self._nested_outputs
271
272 @property
AttributeError: ‘Sequential’ object has no attribute ‘_nested_outputs’