i am having error as using a tf.Tensor
as a Python bool
is not allowed in Graph execution. Use Eager execution or decorate this function with @tf.function.
sorry this issue is solved but i am having next error again:
‘MaxPooling2D’ object has no attribute ‘lower’
And i am using:
P1 = tf.keras.layers.MaxPool2D(pool_size=(8, 8), strides=(8, 8),padding = ‘SAME’)
CONV2D: 16 filters 2x2, stride 1, padding ‘SAME’
Z2 = tf.keras.layers.Conv2D(filters=16, kernel_size=(2, 2), strides=(1, 1),padding = ‘SAME’)
RELU
A2 = tf.keras.layers.ReLU()
MAXPOOL: window 4x4, stride 4, padding ‘SAME’
P2 = tf.keras.layers.MaxPool2D(pool_size=(4, 4), strides=(4, 4),padding = ‘SAME’)
I’m just guessing, maybe those “SAME” should be “same”. So it doesn’t have to convert them to lower-case.
Hi
I am sorry but it didnt work. same error is coming
Remember that you are doing the Keras “Functional API” here, not the Sequential API. So in addition to specifying the parameters to the MaxPool2D, you also need to invoke it with an input value, right? The syntax is a bit confusing at first, but when you say this:
tfl.MaxPool2D( ... some parameter settings ... )
What that does is return a MaxPool2D function with the settings you have asked for. Now you need to invoke that function with an input value. That’s the big difference with the Functional API: the input is explicit, instead of implicitly being the output of the previous layer.
Note that you’ve made the same mistake on the Conv2D and ReLU layers as well. In the ReLU case, the syntax looks even weirder. You say
tfl.ReLU()
to create the function and then you pass it an input, so it looks like:
outputTensor = tfl.ReLU()(inputTensor)
Great stuff. Dunno what they were thinking when they designed this, but hey it’s easier to use than TF 1.0 …
Thanks much. Yeah it works
Thanks, through your clarification I found my error:
outputTensor = tfl.ReLU(inputTensor)
instead of
outputTensor = tfl.ReLU()(inputTensor)
Yes, the syntax takes some getting used to and they don’t give us as much instruction on this in the notebooks as one might wish. It’s worth taking a look at this thread put together by a fellow student for a great introduction to the Sequential and Functional APIs.