Skip to content
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

tf.Variable support #62

Open
gonzojive opened this issue Oct 21, 2021 · 1 comment
Open

tf.Variable support #62

gonzojive opened this issue Oct 21, 2021 · 1 comment

Comments

@gonzojive
Copy link

This is related to #23

Why does the API not support tf.Variable? What would it take to add it?

@gonzojive gonzojive changed the title tf.Variable support for golang tf.Variable support Oct 21, 2021
@galeone
Copy link
Owner

galeone commented Oct 22, 2021

Because tfgo uses the official TensorFlow''s Go bindings under the hood (a fork I created because these bindings are not go-gettable) and these bindings do not support tf.Variable.

The Go bindings are almost abandoned, just think about that we are constrained to the static graph + session execution (without tf.Variable support, for using them you have to define the model in Python as a SavedModel and then load it in tfgo) while the C API has the support for the Eager Execution and creating variables on the fly.

For adding the support for tf.Variable the only possible way is to write in my fork ( https://github.com/galeone/tensorflow ) the tf.Variable support in C, and expose them in Go via cgo.

But it's not worth it IMO since the support for static-graph + session execution is enough for every application: just write the graph in Python (a function decorated with @tf.function) and export it as a SavedModel - the graph can contain any layer, with variables and so on. The exported graph can be loaded into tfgo and used, being the state (the value of the variables) managed by the TensorFlow runtime (the C library) and not by the bindings.

What it would be worth doing, instead, is exposing all the new eager C API to the Go bindings (my fork) - but that's a lot of work and people at Google are not doing it, hence I suppose it's something not trivial

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

No branches or pull requests

2 participants