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

[MXNET-145] Remove the dependences of mx.io and mx.initializer on the numpy's global random number generator #10260

Merged
merged 2 commits into from Mar 28, 2018

Conversation

asitstands
Copy link
Contributor

Description

This PR removes the dependences of mx.io and mx.initializer on the numpy's global random number generator. The dependences are not sound as they introduce unnecessary coupling with user's environment and confuse newcomers about seeding.

Checklist

Essentials

Please feel free to remove inapplicable items for your PR.

  • The PR title starts with [MXNET-$JIRA_ID], where $JIRA_ID refers to the relevant JIRA issue created (except PRs with tiny changes)
  • 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
  • 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

Comments

  • If this PR is accepted, I'll make similar PRs removing the dependences on python's and numpy's global random number generators from rnn/io, gluon's samplers and so on.

@asitstands asitstands requested a review from szha as a code owner March 27, 2018 06:27
@@ -530,9 +530,9 @@ def _init_weight(self, _, arr):
nout = arr.shape[0]
nin = np.prod(arr.shape[1:])
if self.rand_type == "uniform":
tmp = np.random.uniform(-1.0, 1.0, (nout, nin))
tmp = random.uniform(-1.0, 1.0, shape=(nout, nin)).asnumpy()
Copy link
Contributor

Choose a reason for hiding this comment

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

are these asnumpys necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Numpy's SVD is applied to tmp array, so the conversions are needed. Currently mxnet seems not have SVD. There is a simple workaround to perform SVD using eigen decomposition (so using syevd), however it is not so efficient.

@piiswrong piiswrong merged commit fdb5664 into apache:master Mar 28, 2018
jinhuang415 pushed a commit to jinhuang415/incubator-mxnet that referenced this pull request Mar 30, 2018
… numpy's global random number generator (apache#10260)

* Remove the dependence of mx.io on the global random number generator of numpy

* Remove the dependence of mx.initializer on the global random number generator of numpy
cjolivier01 pushed a commit to cjolivier01/mxnet that referenced this pull request Mar 30, 2018
…r on the numpy's global random number generator (apache#10260)"

This reverts commit fdb5664.
haojin2 pushed a commit to haojin2/incubator-mxnet that referenced this pull request Apr 2, 2018
… numpy's global random number generator (apache#10260)

* Remove the dependence of mx.io on the global random number generator of numpy

* Remove the dependence of mx.initializer on the global random number generator of numpy
@asitstands asitstands deleted the rndfix_io_init branch April 11, 2018 08:55
rahul003 pushed a commit to rahul003/mxnet that referenced this pull request Jun 4, 2018
… numpy's global random number generator (apache#10260)

* Remove the dependence of mx.io on the global random number generator of numpy

* Remove the dependence of mx.initializer on the global random number generator of numpy
zheng-da pushed a commit to zheng-da/incubator-mxnet that referenced this pull request Jun 28, 2018
… numpy's global random number generator (apache#10260)

* Remove the dependence of mx.io on the global random number generator of numpy

* Remove the dependence of mx.initializer on the global random number generator of numpy
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.

None yet

2 participants