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
".