Memory Leak when calling fit() often

Hello,

Currently I have a working Tensorflow network that I use for Reinforcement Learning. However, I seem to have a memory leak in the Tensorflow part, probably because I did not close everything that is required. Because it is a RL script, I have to call the fit method of my code (see below) several times. This seems to cause a Memory Leak. Anyone an idea for what I am doing wrong?

Thanks in advance!

And the network construction:

It’s probably better to create the tensors directly using the ndarray functionality rather than making eager mode constants and then getting tensors out of them. That will allow you to not keep getting the ops and using the default eager session.

You also don’t seem to be storing the op produced by the minimize call, which is what actually updates the model parameters. Are you accessing it directly by name some other way?

1 Like

Thank you very much for the fast response. This indeed fixed all issues, thank you!
I am indeed accessing it by name, “train”.