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

image938×543 28.2 KB

Hope guys help me find the bug.
This is my model code:
encode model:

image936×1257 153 KB

decode model:

image825×806 90.4 KB

discriminator model:

image1171×687 79.6 KB

training step:

image1512×1142 219 KB

loss function:

image884×65 7.83 KB


image1288×130 17.7 KB


image737×178 22.7 KB


image890×58 10.1 KB



image946×56 9.48 KB

There is I have check:

I checked my dataset. There is not none data.
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.