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

How to run an operation which produces no output? (Or, how to run equivalent of global_variables_initializer) #142

Open
mikeoconnor0308 opened this issue Sep 13, 2017 · 3 comments

Comments

@mikeoconnor0308
Copy link

How do I run an operation which produces no output? I'm trying to run a graph built using the python api, which uses the python method initialize_global_variables. I figured a way to do this was to run the resulting Tensor operation by getting its name (which is init). This leads to the following C# code:

var initOp = graph["init_1"];
runner.Fetch(graph["outputs"][0]);
var output_init = runner.Run(initOp[0]);
var output = runner.Run();

This results in the following exception:

{TensorFlow.TFException: Tried to fetch data for 'init_1:0', which produces no output.  To run to a node but not fetch any data, pass 'init_1:0' as an argument to the 'target_node_names' argument of the Session::Run API.

I can't see a straightforward way of doing this, unless I'm missing something?

@mikeoconnor0308
Copy link
Author

I've actually solved my specific problem (by RTFM), I wasn't storing all the variables from my model on the python side. Storing everything by making use of the freeze_graph functionality creates a GraphDef that contains all the variables as constants. I've put a gist for doing this here, in case any other tensorflow novices end up running into the same hurdle.

Regardless, I'm still curious as to how one would run an operation with no output from TensorflowSharp?

@sqlBender
Copy link

"RTFM" what Manual...

@moore3930
Copy link

You can use runner.AddTarget(ops) to do that.

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

3 participants