Skip to content

Variable class (like tf.Variable) that supports eager mode #170

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
rnett opened this issue Dec 10, 2020 · 1 comment
Open

Variable class (like tf.Variable) that supports eager mode #170

rnett opened this issue Dec 10, 2020 · 1 comment

Comments

@rnett
Copy link
Contributor

rnett commented Dec 10, 2020

I've been looking at adding a tf.Variable like class, that would work in eager and graph mode (the variable op doesn't work in eager), and register itself in the execution environment. It's not terribly useful until we get eager gradient support, but it's not dependent on it either so there's no reason to wait.

Eager mode is easy, just have a field. For graph, we can store a Variable op, assign to it, but return/expose the return of the assign (it's the new value). The assigns can take the last assign as a control dep.

I've got a draft here I can PR, but I'm not sure how much the type system refactor would affect it. At a minimum I don't see a reason to merge before #160.

@rnett
Copy link
Contributor Author

rnett commented Dec 29, 2020

After looking into this, it's a bit more complicated: we will (I assume) want to use the new Resource APIs, not the variable op (which should probably be deprecated once this is done). See https://github.com/tensorflow/tensorflow/blob/v2.4.0/tensorflow/python/ops/resource_variable_ops.py. It works in eager and graph mode, and isn't that much harder to do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant