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

[MXNET-160] Fix for issue 9062 #10413

Merged
merged 2 commits into from
Apr 5, 2018
Merged

[MXNET-160] Fix for issue 9062 #10413

merged 2 commits into from
Apr 5, 2018

Conversation

haojin2
Copy link
Contributor

@haojin2 haojin2 commented Apr 5, 2018

Description

Bug fix for issue #9062

Checklist

Essentials

  • The PR title starts with [MXNET-160]
  • 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

Changes

  • Fix the typo in Shape function of sample_multinomial_op.h
  • Add test coverage to verify the fix

@haojin2 haojin2 requested a review from cjolivier01 as a code owner April 5, 2018 00:23
@haojin2 haojin2 changed the title Fix for issue 9062 [MXNET-160] Fix for issue 9062 Apr 5, 2018
@haojin2
Copy link
Contributor Author

haojin2 commented Apr 5, 2018

@eric-haibin-lin @rahul003 @reminisce @anirudh2290 This is bug fix for #9062, please give a review if you have a minute. Thanks!

freq = np.bincount(y[i,:], minlength=5)/np.float32(samples)*x[i,:].sum()
mx.test_utils.assert_almost_equal(freq, x[i], rtol=0.20)
rprob = x[i][y[i]]/x[i].sum()
mx.test_utils.assert_almost_equal(np.log(rprob), prob.asnumpy()[i])
Copy link
Member

Choose a reason for hiding this comment

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

should we provide specific atol ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is the default not 1e-20?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The current test can always pass, I guess the default 1e-20 value should be okay?

Copy link
Contributor

Choose a reason for hiding this comment

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

Should provide atol to avoid failure when comparing two numbers that are close to zero.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, thanks!

real_dx = np.zeros((5,))
for j in range(samples):
real_dx[y[i][j]] += 5.0 / rprob[j]
mx.test_utils.assert_almost_equal(real_dx, dx[i, :], rtol=1e-4)
Copy link
Member

Choose a reason for hiding this comment

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

same question as above.

@piiswrong piiswrong merged commit 4342bd1 into apache:master Apr 5, 2018
@haojin2 haojin2 deleted the issue_9062 branch April 5, 2018 19:57
rahul003 pushed a commit to rahul003/mxnet that referenced this pull request Jun 4, 2018
* fix typo in sample_multinomial_op.h (issue apache#9062)

* add test case for 1D prob input case
zheng-da pushed a commit to zheng-da/incubator-mxnet that referenced this pull request Jun 28, 2018
* fix typo in sample_multinomial_op.h (issue apache#9062)

* add test case for 1D prob input case
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.

4 participants