ó R;]c@sjdZddlZddlmZddlmZyddlTWnek rSnXdgZd„Z dS( sContrib Symbol API of MXNet.i˙˙˙˙Ni(tuniform(tSymbol(t*t rand_zipfianc Csęt|tƒs%tdt|ƒƒ‚tj|dƒ}td|d|fddƒ}|jƒdjdƒ|}|jdƒ}|d|d jƒ|}||}|jdƒ}|d|d jƒ|} | |} ||| fS( séDraw random samples from an approximately log-uniform or Zipfian distribution. This operation randomly samples *num_sampled* candidates the range of integers [0, range_max). The elements of sampled_candidates are drawn with replacement from the base distribution. The base distribution for this operator is an approximately log-uniform or Zipfian distribution: P(class) = (log(class + 2) - log(class + 1)) / log(range_max + 1) This sampler is useful when the true classes approximately follow such a distribution. For example, if the classes represent words in a lexicon sorted in decreasing order of frequency. If your classes are not ordered by decreasing frequency, do not use this op. Additionaly, it also returns the number of times each of the true classes and the sampled classes is expected to occur. Parameters ---------- true_classes : Symbol The target classes in 1-D. num_sampled: int The number of classes to randomly sample. range_max: int The number of possible classes. Returns ------- samples: Symbol The sampled candidate classes in 1-D `int64` dtype. expected_count_true: Symbol The expected count for true classes in 1-D `float64` dtype. expected_count_sample: Symbol The expected count for sampled candidates in 1-D `float64` dtype. 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] >>> exp_count_true [ 0.12453879] >>> exp_count_sample [ 0.22629439 0.12453879 0.12453879 0.12453879] sunexpected type %siitshapetdtypetfloat64tint64g@gđ?( t isinstanceRtAssertionErrorttypetmathtlogRtexptastype( t true_classest num_sampledt range_maxt log_rangetrandtsampled_classestexpected_prob_truetexpected_count_truetsampled_cls_fp64texpected_prob_sampledtexpected_count_sampled((sT/usr/local/lib/python2.7/site-packages/mxnet-1.2.1-py2.7.egg/mxnet/symbol/contrib.pyRs1%  ( t__doc__R trandomRtsymbolRt gen_contribt ImportErrort__all__R(((sT/usr/local/lib/python2.7/site-packages/mxnet-1.2.1-py2.7.egg/mxnet/symbol/contrib.pyts