Skip to content

Commit

Permalink
Fixing the doc for symbolic version of rand_zipfian (apache#13978)
Browse files Browse the repository at this point in the history
* Fixes apache#12779
  • Loading branch information
safrooze authored and stephenrawls committed Feb 16, 2019
1 parent 3cd0630 commit 3dcf592
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 3dcf592

Please sign in to comment.