Convolutional Model Exercise 2 week 1 Assignment 2- convolution neural networks

Hi ,

I keep getting the error,
NameError: name ‘input_shape’ is not defined
I am unable to understand why I get this error. Below is what I applied.
I don’t know how to correct it. Please help.

Sounds strange. Can you post the full body of convolutional_model(input_shape) and also the full exception trace.

# code removed - moderator

model = tf.keras.Model(inputs=input_img, outputs=outputs)
return model
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-31-f1284300b767> in <module>
----> 1 conv_model = convolutional_model((64, 64, 3))
      2 conv_model.compile(optimizer='adam',
      3                   loss='categorical_crossentropy',
      4                   metrics=['accuracy'])
      5 conv_model.summary()

<ipython-input-30-76e9a42a1a77> in convolutional_model(X)
     17     """
     18 
---> 19     input_img = tf.keras.Input(shape=input_shape)
     20 
     21 

NameError: name 'input_shape' is not defined

@jonaslalin

Download and send me the notebook as private message please. I still don’t see it.

I have sent you a private message Please check

1 Like

Indentation? Might be an artifact of cut and paste, but it looks to me that the line with input_shape is left justified

1 Like

Good catch @ai_curious! Yes exactly, @Priyadarshan_S needs to fix the indentation.

[code removed - moderator]

When everything is working, please remove your solution code.

1 Like

Thank you so much @ai_curious. Usually, the interpreter throws an indentation error when the indent is the problem. But I agree here. I called the input shape outside of the function.

1 Like

Thanks, @jonaslalin for taking the time to find my mistake. I really Appreciate it. Removing the code

1 Like

Glad to help and thanks for the feedback. When you’ve written as much buggy code as I have, you get a sense for where they like to hide :wink:

One might think a pattern of a function definition with no body followed by a left justified line is something an editor or interpreter could be set up to detect, but you didn’t get much automated help in this case.