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

Fixing the doc example for symbolic version of rand_zipfian #13978

Merged
merged 1 commit into from
Jan 24, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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