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

Simple example for getting input and output nodes of TF graph #1040

Closed
GalOshri opened this issue Sep 26, 2018 · 4 comments
Closed

Simple example for getting input and output nodes of TF graph #1040

GalOshri opened this issue Sep 26, 2018 · 4 comments
Assignees
Labels
documentation Related to documentation of ML.NET enhancement New feature or request need info This issue needs more info before triage P0 Priority of the issue for triage purpose: IMPORTANT, needs to be fixed right away.

Comments

@GalOshri
Copy link
Contributor

#862 enabled extracting information about nodes in a TF model. However, it's not completely clear how to extract the most important information for using the model with the TF Transform: what are the input and output nodes?

The DnnAnalyzer shows how to view all the nodes, but this can be improved to identify which are the input and output nodes (based on the other links) to make this easier.

Proposal: either modify DnnAnalyzer to identify the input and output nodes, or provide a separate sample that does this.

@shauheen shauheen added enhancement New feature or request documentation Related to documentation of ML.NET labels Sep 26, 2018
@shauheen shauheen added this to the 1018 milestone Oct 5, 2018
@shauheen shauheen added the need info This issue needs more info before triage label Oct 5, 2018
@shauheen shauheen removed this from the 1018 milestone Oct 5, 2018
@Zruty0
Copy link
Contributor

Zruty0 commented Oct 7, 2018

Can we approach this from scenario-first perspective? What do we want to have? A commandline tool to inspect TF models? A programmatic way to do this? Or something else?

What is the anticipated usage pattern?

Also, I think, 'output' nodes in TF is not an actual TF term. What do you call an 'output' node?

@GalOshri
Copy link
Contributor Author

GalOshri commented Oct 7, 2018

Great questions. The scenario is that I want to build an ML.NET model that takes advantage of a pretrained TensorFlow model I found on the web. Suppose I am doing image classification and want to use the Inception model that I found here. For a simple scenario, I just want to give my image as input and get the scores the model provides. For a more advanced scenario, I want to get the penultimate layer output so I can use it as a featurizer.

To use the model in ML.NET, I need to know:

  • What is the input node? What format of data does it expect?
  • What is the name of the output node with the scores across the 1000 classes?
  • For the advanced scenario: what is the penultimate layer node?

I could perhaps get this information through a tool such as Netron, but the APIs this issue refers to could make this easier for me.

Once I have this information, I can plug this into my ML.NET pipeline and start using the Inception model.

I don't have a strong opinion about whether this should be programmatic or through a CLI. A CLI feels more natural as I want this information when I'm developing my training app and don't want to open up a separate app to get this info (I don't need it as part of my training app).

Some TF graphs are more complicated so identifying the input and output might not be straightforward. A simple heuristic could be that input nodes are ones that don't have any other node providing data to them. Output nodes are ones that aren't used as input to any other node.

Thoughts?

@shmoradims shmoradims added P1 Priority of the issue for triage purpose: Needs to be fixed soon. P0 Priority of the issue for triage purpose: IMPORTANT, needs to be fixed right away. and removed P1 Priority of the issue for triage purpose: Needs to be fixed soon. labels May 21, 2019
@codemzs codemzs assigned zeahmed and unassigned yaeldekel May 22, 2019
@zeahmed
Copy link
Contributor

zeahmed commented May 22, 2019

There is already a programmatic way get all the input nodes ('Placeholder') from the graph.

public DataViewSchema GetInputSchema()

However, its not possible to get the output nodes as they are not marked specifically. So, user will have to inspect the complete model to see the outputs.

@zeahmed
Copy link
Contributor

zeahmed commented May 22, 2019

I am closing it. Reopen it if necessary.

@zeahmed zeahmed closed this as completed May 22, 2019
@ghost ghost locked as resolved and limited conversation to collaborators Mar 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Related to documentation of ML.NET enhancement New feature or request need info This issue needs more info before triage P0 Priority of the issue for triage purpose: IMPORTANT, needs to be fixed right away.
Projects
None yet
Development

No branches or pull requests

6 participants