Skip to content

Add more robust error checking to rewrite.change_batch_size() #14

Description

@frreiss

The change_batch_size rewrite (see #4) works by putting the new batch size in place at the input nodes, then propagating the batch size through the rest of the graph by shape inference. If the user does not specify all the input nodes, then the remaining nodes will produce a conflicting batch sizes. This can result in an error (if a node ends up with two mutually inconsistent input batch sizes) or in the rewrite having no apparent effect on output batch sizes (if the user changes the batch size to None). As I noted in #13, the script batch_size_example.py has the latter problem. The batch size changes to None, but implicit inputs inside the batch normalization layers change the output batch size to 64.

The proper fix for this problem is as follows:

  • Add error checking code to the change_batch_size rewrite. If the batch size of a node doesn't change, or if type inference fails; then the rewrite should output a detailed error message. The message should contain the name of the node, the node's input shapes, and the names of the nodes that produced those shapes).
  • Use the error checking code to track down all the hidden inputs in the batch_size_example.py script and add them to the inputs set. Note that it may be necessary to run the input graph through the freeze graph script to remove variables. You can invoke the freeze graph script from python by adding from tensorflow.python.tools import freeze_graph to the beginning of your script and calling freeze_graph. freeze_graph_with_def_protos() directly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions