Last active
November 20, 2021 17:21
-
-
Save danijar/720394a9071a03413be8a60852374aa4 to your computer and use it in GitHub Desktop.
TensorFlow decorator to share variables between calls. Works for both functions and methods.
@albertz Yes, I use the object ID for the variable scope, so that different instances of the same class have their own variables. You could make it a convention that model classes must implement a model.name
attribute and use that for the scope name. Or you only save/load the variables inside a scope using export_scoped_meta_graph()
and import_scoped_meta_graph()
.
I've updated the code to include a fix and to use the self.name
attribute of model classes if available, and fall back to id(self)
otherwise.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
So this will create different variable names on each execution because of the usage of
id()
for the variable names. This makes it hard to store/load models from disk.