In the exercise2-convolution_model, I finished the grade function, but in the model compile, it gaves me error like this: OperatorNotAllowedInGraphError: using a tf.Tensor
as a Python bool
is not allowed in Graph execution. Use Eager execution or decorate this function with @tf.function. I googled, but I found out I cannot modify the model compile lines. My tensorflow is 2.7.0 vision. Can you help me out?
It sounds like you must be executing the notebooks on your own computer. That is not a good idea if you want to access the grader. It’s also not guaranteed to work with whatever versions of everything you happen to have installed locally.
Here is the version of TF used by the notebook on the website:
print(f"TF version {tf.__version__}")
print(f"numpy version {np.__version__}")
TF version 2.3.0
numpy version 1.18.4
But the error you quote sounds like there is a bug in your code that’s probably not related to the versions. That section of the exercise uses the Functional API, so every layer involves two steps:
- Invoke the layer function with the parameters you want. That gives you back a function.
- You invoke that function with an input Tensor and it gives you an output Tensor.
It sounds like you probably left out step 1) in at least one of the layers. Here’s a thread that gives a good introduction to the Sequential and Functional Keras APIs.