0
votes

So I tried using the function InteractiveSession.close() If I do it says:

TypeError: close() missing 1 required positional argument: 'self'

But when I do InteractiveSession.close(self) It gives me the Error

NameError: name 'self' is not defined

I don't know what to do can anyone help? Thanks in Advance!!!!

1

1 Answers

1
votes

You are expected to call .close() on an instance of the InteractiveSession class, not the class itself.

For example, if you have an instance of InteractiveSession in the variable session, you would write session.close().

Also note that TF developers helpfully provided a usage example here: https://www.tensorflow.org/api_docs/python/tf/compat/v1/InteractiveSession

This question reflects a basic but common misunderstanding about how classes work in Python. There are many documents and guides that can help you on this topic, for example here is one I just found with a DDG search: https://medium.com/quick-code/understanding-self-in-python-a3704319e5f0