C4 W2 A2: Unable to locate output

Downloading data from https://storage.googleapis.com/tensorflow/keras-applications/mobilenet_v2/mobilenet_v2_weights_tf_dim_ordering_tf_kernels_1.0_160_no_top.h5
9412608/9406464 [==============================] - 0s 0us/step
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-17-11ffc7a7acb3> in <module>
----> 1 model2 = alpaca_model(IMG_SIZE, data_augmentation)

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

NameError: name 'outputs' is not defined

Hey @Shubham_Singh3,
As per the error you have shown, it seems that you haven’t stored the output of your alpaca_model in the outputs variable. Can you please ensure that you have stored the output of the last layer of the alpaca_model in a variable named outputs. I hope this helps.

Regards,
Elemento

1 Like
# UNQ_C2
# GRADED FUNCTION
def alpaca_model(image_shape=IMG_SIZE, data_augmentation=data_augmenter()):
    ''' Define a tf.keras model for binary classification out of the MobileNetV2 model
    Arguments:
        image_shape -- Image width and height
        data_augmentation -- data augmentation function
    Returns:
    Returns:
        tf.keras.model
    '''
    
    input_shape = image_shape + (3,)
    
    ### START CODE HERE
    % code removed
    ### END CODE HERE
    
    model = tf.keras.Model(inputs, outputs)
    
    return model

That seems to be the error. “prediction_layer” is not the correct variable name for the outputs.

And please do not post your code on the Forum. That breaks the course honor Code. I have edited your post.

If a mentor needs to see your code, we will ask you to send it via a private message.

1 Like

You’ve showed us the code. Now please point out exactly where in that code any assignment is made to the variable outputs? This is pretty basic debugging. The error message told you exactly what is wrong. Now you just have to use the ^F search on that page to find all occurrences of outputs, right? There’s only one that I can see and it is a reference, not an assignment. So why did that happen?

1 Like

sorry, I missed writing outputs = prediction_layer(x).Thanks

You don’t need a variable named “prediction_layer” at all.