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

support shared parameter in summary #11379

Merged
merged 1 commit into from
Jun 29, 2018
Merged

support shared parameter in summary #11379

merged 1 commit into from
Jun 29, 2018

Conversation

szha
Copy link
Member

@szha szha commented Jun 24, 2018

Description

print out number of parameters that are shared, in block summary.

Checklist

Essentials

Please feel free to remove inapplicable items for your PR.

  • 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)
  • Code is well-documented:
  • Check the API doc at http://mxnet-ci-doc.s3-accelerate.dualstack.amazonaws.com/PR-$PR_ID/$BUILD_ID/index.html
  • To the my best knowledge, examples are either not affected by this change, or have been fixed to be compatible with this change

Changes

  • print shared parameter count in summary

@szha
Copy link
Member Author

szha commented Jun 24, 2018

For network like this:

net2 = nn.Sequential()
with net2.name_scope():
    net2.add(nn.Embedding(40, 30))
    net2.add(gluon.rnn.LSTM(30))
    net2.add(nn.Dense(40, flatten=False, params=net2[0].params))
net2.initialize()
net2.summary(mx.nd.ones((80, 32)))

the printed summary looks like:

--------------------------------------------------------------------------------
        Layer (type)                                Output Shape         Param #
================================================================================
               Input                                    (80, 32)               0
         Embedding-1                                (80, 32, 30)            1200
              LSTM-2                                (80, 32, 30)            7440
             Dense-3                                (80, 32, 40)            1240
================================================================================
Total params: 9880
Trainable params: 9880
Non-trainable params: 0
Shared params: 1200          # added in this PR
--------------------------------------------------------------------------------

@szha szha force-pushed the sum_share branch 2 times, most recently from 0376661 to a50ef3f Compare June 28, 2018 23:43
@szha szha merged commit 36f2aae into apache:master Jun 29, 2018
@szha szha deleted the sum_share branch June 29, 2018 02:15
XinYao1994 pushed a commit to XinYao1994/incubator-mxnet that referenced this pull request Aug 29, 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