Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

add axes support for dropouts in gluon #10032

Merged
merged 1 commit into from
Mar 8, 2018
Merged

Conversation

szha
Copy link
Member

@szha szha commented Mar 8, 2018

Description

add axes support for dropouts in gluon

Checklist

Essentials

  • Passed code style checking (make lint)
  • Changes are complete (i.e. I finished coding on this PR)
  • All changes have test coverage:
  • Unit tests are added for small changes to verify correctness (e.g. adding a new operator)
  • Nightly tests are added for complicated/long-running ones (e.g. changing distributed kvstore)
  • Build tests will be added for build configuration changes (e.g. adding a new build option with NCCL)
  • Code is well-documented:
  • For user-facing API changes, API doc string has been updated.
  • For new C++ functions in header files, their functionalities and arguments are documented.
  • For new examples, README.md is added to explain the what the example does, the source of the dataset, expected performance on test set and reference to the original paper if applicable
  • To the my best knowledge, examples are either not affected by this change, or have been fixed to be compatible with this change

Changes

  • add dropout axes support in Dropout, VariationalDropoutCell

@@ -239,15 +241,16 @@ class Dropout(HybridBlock):
`Dropout: A Simple Way to Prevent Neural Networks from Overfitting
<http://www.cs.toronto.edu/~rsalakhu/papers/srivastava14a.pdf>`_
"""
def __init__(self, rate, **kwargs):
def __init__(self, rate, axes=(), **kwargs):
Copy link
Member

Choose a reason for hiding this comment

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

Default to None?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is the same default value as the one added in Dropout op. I set it this way so that I don't have to handle None.

compactshape[axis] = 1
compactx = mx.random.uniform(shape=tuple(compactshape))
broadcastx = compactx.broadcast_to(shape)
dropouty = mx.gluon.nn.Dropout(rate=ratio, axes=axes)(broadcastx)
Copy link
Member

Choose a reason for hiding this comment

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

May need consider to improve the test in the future. Currently there's no guarantee that the observed dropout ratio matches the given dropout ratio.

Copy link
Member

@sxjscience sxjscience left a comment

Choose a reason for hiding this comment

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

The axes=() problem and the test should be revised later. The overall logic looks good.

@sxjscience sxjscience merged commit 649b086 into apache:master Mar 8, 2018
@szha szha deleted the var_drop_op branch March 8, 2018 20:47
jinhuang415 pushed a commit to jinhuang415/incubator-mxnet that referenced this pull request Mar 30, 2018
rahul003 pushed a commit to rahul003/mxnet that referenced this pull request Jun 4, 2018
zheng-da pushed a commit to zheng-da/incubator-mxnet that referenced this pull request Jun 28, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants