Skip to content

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

Closed

Description

@GalOshri

#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.

Activity

  1. added this to the 1018 milestone on Oct 5, 2018
  2. removed this from the 1018 milestone on Oct 5, 2018
  3. Zruty0 commented on Oct 7, 2018

    @Zruty0
    Contributor

    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?

  4. GalOshri commented on Oct 7, 2018

    @GalOshri
    ContributorAuthor

    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?

  5. added and removed on May 21, 2019
  6. zeahmed commented on May 22, 2019

    @zeahmed
    Contributor

    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.

  7. zeahmed commented on May 22, 2019

    @zeahmed
    Contributor

    I am closing it. Reopen it if necessary.

  8. ghost locked as resolved and limited conversation to collaborators on Mar 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

documentationRelated to documentation of ML.NETenhancementNew feature or request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions