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

Commit

Permalink
Fixing the doc for symbolic version of rand_zipfian (#13978)
Browse files Browse the repository at this point in the history
* Fixes #12779
  • Loading branch information
safrooze authored and eric-haibin-lin committed Jan 24, 2019
1 parent dfb397e commit b30fba6
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions python/mxnet/symbol/contrib.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,14 @@ def rand_zipfian(true_classes, num_sampled, range_max):
Examples
--------
>>> true_cls = mx.nd.array([3])
>>> samples, exp_count_true, exp_count_sample = mx.nd.contrib.rand_zipfian(true_cls, 4, 5)
>>> samples
[1 3 3 3]
<NDArray 4 @cpu(0)>
>>> exp_count_true
[ 0.12453879]
<NDArray 1 @cpu(0)>
>>> exp_count_sample
[ 0.22629439 0.12453879 0.12453879 0.12453879]
<NDArray 4 @cpu(0)>
>>> true_cls = mx.sym.Variable('true_cls')
>>> samples, exp_count_true, exp_count_sample = mx.sym.contrib.rand_zipfian(true_cls, 4, 5)
>>> samples.eval(true_cls=mx.nd.array([3]))[0].asnumpy()
array([1, 3, 3, 3])
>>> exp_count_true.eval(true_cls=mx.nd.array([3]))[0].asnumpy()
array([0.12453879])
>>> exp_count_sample.eval(true_cls=mx.nd.array([3]))[0].asnumpy()
array([0.22629439, 0.12453879, 0.12453879, 0.12453879])
"""
assert(isinstance(true_classes, Symbol)), "unexpected type %s" % type(true_classes)
log_range = math.log(range_max + 1)
Expand Down

0 comments on commit b30fba6

Please sign in to comment.