Tensorflow problem: The loss return None, and show Error message:Attempting to capture an EagerTensor without building a function

Hi guys, I try to implement the model for tensorflow2.5.0, but when I run the model, its print my loss return ‘none’, and show the error message: “RuntimeError: Attempting to capture an EagerTensor without building a function”.


Hope guys help me find the bug.

This is my model code:
encode model:

decode model:

discriminator model:

training step:

loss function:





image

There is I have check:

  1. I checked my dataset. There is not none data.
  2. I checked my loss function, there is no nd.array, I change in tf.tensor.

This is my first time ask question on the website, if I need provide other code information to solve problem, I will upload. Thanks.

If you can share a running Colab to reproduce this it could be ideal.

1 Like

Here is colab playground:

Ok, but It is protected.