What is the syntax to be used for feed_dict in TensorFlow C ++?

I want to plot and prepare a graph in TensorFlow C ++ that has two layers and pass it by a given matrix as input.

I have two different examples for the syntax:

Official C ++ example (line # 129)

stack overflow

They seem to contradict each other regarding the exact syntax of the "input" parameter for the tensorflow :: Session :: Run () method

Should it be "placeholder_name: 0" or "placeholder_name"?

+3


source to share


1 answer


Either one works. The name is passed through ParseTensorName , which assumes that names without a colon have an output index of 0. To verify this, we can add ": 0" to the end of the feed name in DirectSessionMinusAXTest :: TestFeed :

std::vector<std::pair<string, Tensor>> inputs = {{x_, t}};

      

becomes



std::vector<std::pair<string, Tensor>> inputs = {{x_ + ":0", t}};

      

and it still passes.

The only case when you need to pass the output index (more precisely, the only case when it should be needed, may be some code that cannot be canonicalized) is if you feed a tensor that is not a null result of an operation (for example, "unique: 1" ). This is quite rare, as constant and override operators are the most likely feed targets and only have one output.

+1


source







All Articles