Week 1 Assignment 2 Exercise 2

using a tf.Tensor as a Python bool is not allowed in Graph execution. Use Eager execution or decorate this function with @tf.function.
This is my error when i am executing convolution_model function.
Can someone please help with this?
Below is the part of my code:

Z1 = tf.keras.layers.Conv2D(filters= 8 , kernel_size= (4,4) ,strides = (1,1), padding='same')(input_img)

A1 = tf.keras.layers.ReLU(Z1)

P1 = tf.keras.layers.MaxPool2D(A1, pool_size=(8, 8), strides=(8,8), padding='same')

Z2 = tf.keras.layers.Conv2D(filters= 16 , kernel_size= (2,2), strides = (1,1) , padding='same')(P1)

A2 = tf.keras.layers.ReLU(Z2)

P2 = tf.keras.layers.MaxPool2D(A2, pool_size=(4, 4), strides=(4,4), padding='same')

F = tf.keras.layers.Flatten(P2)
    
outputs = tf.keras.layers.Dense(units=6, activation='softmax')(F)
1 Like

@ddashutosh
I think you are missing the (A1) and (A2) parameters after your max pool layer statements.
Also your syntax for the ReLU layers may not be correct.

In my code, the A1 and A2 are separate (…) arguments, not embedded in the layer call.

It is still showing error for failed test.

Please see this other thread for an explanation of the issue.