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

Create mapping from model for model.Exec #32

Open
Arnold1 opened this issue Feb 17, 2020 · 4 comments
Open

Create mapping from model for model.Exec #32

Arnold1 opened this issue Feb 17, 2020 · 4 comments

Comments

@Arnold1
Copy link

Arnold1 commented Feb 17, 2020

Hi,

Is there a way to automatically create the mapping for the Placeholder (e.g. Placeholder_1) to the input name (e.g. Height) from the model?

Also is there a way to automatically read the "prob_out" from the model?

[]tf.Output and map[tf.Output]*tf.Tensor are both used for model.Exec:

height, _ := tf.NewTensor([1]int64{"Height"})
width, _ := tf.NewTensor([1]int64{"Width"})

results := model.Exec([]tf.Output{
    model.Op("prob_out", 0),
}, map[tf.Output]*tf.Tensor{
   model.Op("Placeholder_1", 0): height,
   model.Op("Placeholder_2", 0): width,
})

Thanks.

@galeone
Copy link
Owner

galeone commented Feb 18, 2020

Hi @Arnold1
at the moment there isn't a way to do these things automatically, but it should be easy to add some helper function. However, you will have to manually write the input names of your tensors anyway (since although present in the SavedModels file, you are the only one that knows how to map a name e.g. "Placeholder_1" to a meaningful tf.Tensor e.g. height).

@Arnold1
Copy link
Author

Arnold1 commented Feb 20, 2020

@galeone ok, any idea how Tensorflow serving is able to figure it out - maybe there is a way to do it similar? does this mapping have an official name - for input and output tensors?

@ninedraft
Copy link
Contributor

Can we tell placeholders from regular operations? I mean those operations that we get from Graph.Operations()?

@galeone
Copy link
Owner

galeone commented Nov 19, 2020

Yes I guess we can look for the string "placeholder_" in the op.Name (if this is an existing attribute, I don't remember correctly right now).

But this is not general, since during the graph creation phase I can rename the input placeholders as I want, thus the search for the name will fail.

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

No branches or pull requests

3 participants