С4 -CNN-W1-CNNApp: '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'

Dear All,

unfortunately, I got this Error “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.”

could you please, help?

This is a common error. It means you have not implemented the “Functional API” correctly. Here’s a previous thread about the types of mistakes that cause this error.

For future reference, there is a lot of useful history on the Forums here. The Discourse search engine works pretty well. You could have found the previous thread for yourself and saved yourself the time of waiting for someone to respond by searching for "tf.Tensor as a Python bool".

Thank you. Will follow your advice.