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

Use layer stages for all-in-one nets #628

Merged
merged 2 commits into from
Mar 15, 2016

Conversation

lukeyeager
Copy link
Member

Close #605, close #623, close #335

  • Use layer.include.stage to specify train/val/deploy all in a single .prototxt description
  • Stop automatically creating Softmax layers in deploy networks for classification jobs
  • Only set inner_product_param.num_output for classification jobs if it was unset
  • Update the standard networks

TODO:

  • Documentation

@lukeyeager
Copy link
Member Author

Added some documentation:

custom-network-explanation2

Updated with a few suggestions from @jmancewicz - thanks!

if layer.type == 'Softmax':
found_softmax = True
break
assert found_softmax, 'Your deploy network is missing a Softmax layer! Read the documentation for custom networks and/or look at the standard networks for examples.'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did I miss the bit in the documentation where it is explained to the user that a softmax layer is needed to display a probability distribution?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah, good call

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

Use layer.include.stage to specify train/val/deploy all in a single
.prototxt description

Stop automatically creating Softmax layers in deploy networks for
classification jobs

Only set inner_product_param.num_output for classification jobs if it was unset

Update the standard networks
# Check to see if top_k > num_categories
if ( layer.accuracy_param.HasField('top_k') and
layer.accuracy_param.top_k >= num_categories ):
self.logger.warning(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self is not defined here and the layer isn't actually being removed

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops that was sloppy. Thanks for the review! Fixed.

Surprisingly, you can edit an array while enumerating over it. Python is so convenient sometimes.

>>> a = range(10)
>>> for i, x in enumerate(a):
...   if (x%3 == 0):
...     del a[i]
... 
>>> a
[1, 2, 4, 5, 7, 8]

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops I misspoke. The way I implemented it will break if two subsequent layers both have an invalid top_k because the second one won't be processed.

I need to fix that tomorrow...

>>> a = range(10)
>>> for i, x in enumerate(a):
...   print 'Processing %d (%d) ...' % (i, x)
...   if (x%3 == 0):
...     del a[i]
...
Processing 0 (0) ...
Processing 1 (2) ...
Processing 2 (3) ...
Processing 3 (5) ...
Processing 4 (6) ...
Processing 5 (8) ...
Processing 6 (9) ...
>>> a
[1, 2, 4, 5, 7, 8]

@gheinrich
Copy link
Contributor

Great PR! Looks good except for the small omission in the processing of accuracy layers. I've also pushed #632 to update examples.

<ul>
<li>
The <i>num_output</i> for each <b>InnerProduct</b> layer which is a network output gets set to the number of labels in the chosen dataset.
The Deploy network <b>must contain a Softmax layer</b>.
This should produce the only network output.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think GoogleNet does not abide by this principle. Do the auxiliary classifiers need to be sent to SilenceLayers in the deploy network?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually it does. I pruned the auxiliary classifiers from the deploy network (solving #335).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yes indeed, my mistake, sorry.

lukeyeager added a commit that referenced this pull request Mar 15, 2016
Use layer stages for all-in-one nets
@lukeyeager lukeyeager merged commit 4bd5b9e into NVIDIA:master Mar 15, 2016
@lukeyeager lukeyeager deleted the layer-stages branch March 15, 2016 17:48
lukeyeager added a commit that referenced this pull request Mar 15, 2016
gheinrich added a commit to gheinrich/DIGITS that referenced this pull request Apr 14, 2016
Since NVIDIA#628 DIGITS does not overwrite the number of outputs in the last fully-connected layer if it is already set to a value.
If the user accidentally specifies too large a `num_output` then inference will fail as reported on NVIDIA#678.
This change causes classification outputs to be ignored if there is no corresponding label.

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

Successfully merging this pull request may close these issues.

Automatically prune GoogleNet useless branches in the deploy
2 participants