Deep Learning Specialization: Week 2 Transfer Learning with MobileNet

I am getting this error on exercise # 2 on alpaca_model function.
My code follows the instruction of setting base_model trainable = False and implemented global avg pooling tfl.GlobalAveragePooling2D() and dropout set to (.2) and finally the prediction is done using mobilenet_v2.decode_predictions

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-19-11ffc7a7acb3> in <module>
----> 1 model2 = alpaca_model(IMG_SIZE, data_augmentation)

<ipython-input-18-26290cafafdf> in alpaca_model(image_shape, data_augmentation)
     47     ### END CODE HERE
     48 
---> 49     model = tf.keras.Model(inputs, outputs)
     50 
     51     return model

/opt/conda/lib/python3.7/site-packages/tensorflow/python/keras/engine/training.py in __new__(cls, *args, **kwargs)
    240       # Functional model
    241       from tensorflow.python.keras.engine import functional  # pylint: disable=g-import-not-at-top
--> 242       return functional.Functional(*args, **kwargs)
    243     else:
    244       return super(Model, cls).__new__(cls, *args, **kwargs)

/opt/conda/lib/python3.7/site-packages/tensorflow/python/training/tracking/base.py in _method_wrapper(self, *args, **kwargs)
    455     self._self_setattr_tracking = False  # pylint: disable=protected-access
    456     try:
--> 457       result = method(self, *args, **kwargs)
    458     finally:
    459       self._self_setattr_tracking = previous_value  # pylint: disable=protected-access

/opt/conda/lib/python3.7/site-packages/tensorflow/python/keras/engine/functional.py in __init__(self, inputs, outputs, name, trainable)
    113     #     'arguments during initialization. Got an unexpected argument:')
    114     super(Functional, self).__init__(name=name, trainable=trainable)
--> 115     self._init_graph_network(inputs, outputs)
    116 
    117   @trackable.no_automatic_dependency_tracking

/opt/conda/lib/python3.7/site-packages/tensorflow/python/training/tracking/base.py in _method_wrapper(self, *args, **kwargs)
    455     self._self_setattr_tracking = False  # pylint: disable=protected-access
    456     try:
--> 457       result = method(self, *args, **kwargs)
    458     finally:
    459       self._self_setattr_tracking = previous_value  # pylint: disable=protected-access

/opt/conda/lib/python3.7/site-packages/tensorflow/python/keras/engine/functional.py in _init_graph_network(self, inputs, outputs)
    140 
    141     if any(not hasattr(tensor, '_keras_history') for tensor in self.outputs):
--> 142       base_layer_utils.create_keras_history(self._nested_outputs)
    143 
    144     self._validate_graph_inputs_and_outputs()

/opt/conda/lib/python3.7/site-packages/tensorflow/python/keras/engine/base_layer_utils.py in create_keras_history(tensors)
    189       the raw Tensorflow operations.
    190   """
--> 191   _, created_layers = _create_keras_history_helper(tensors, set(), [])
    192   return created_layers
    193 

/opt/conda/lib/python3.7/site-packages/tensorflow/python/keras/engine/base_layer_utils.py in _create_keras_history_helper(tensors, processed_ops, created_layers)
    224                        'op wrapping. Please wrap these ops in a Lambda layer: '
    225                        '\n\n```\n{example}\n```\n'.format(example=example))
--> 226     op = tensor.op  # The Op that created this Tensor.
    227     if op not in processed_ops:
    228       # Recursively set `_keras_history`.

AttributeError: 'str' object has no attribute 'op'

Please click my name and message your notebook as an attachment.

Here are a few hints:

  1. There’s no need to specify input_shape for the Dropout layer. The input shape is suffcient for the very first layer in the network.
  2. outputs should be a Dense layer. See the comment in code. Use decode_predictions to decode the model prediction and not the output of the dropout layer.

Thank you @balaji.ambresh , let me do the updates and re-evaluate the code.