mindspore.ops.LogUniformCandidateSampler

class mindspore.ops.LogUniformCandidateSampler(num_true=1, num_sampled=5, unique=True, range_max=5, seed=0)[源代码]

使用log-uniform(Zipfian)分布对一组类别进行采样。

该操作从整数范围[0, range_max )中随机采样一个采样类( sampled_candidates )的Tensor。

更多参考详见 mindspore.ops.log_uniform_candidate_sampler()

支持平台:

Ascend CPU

样例:

>>> sampler = ops.LogUniformCandidateSampler(2, 5, True, 5)
>>> output1, output2, output3 = sampler(Tensor(np.array([[1, 7], [0, 4], [3, 3]])))
>>> print(output1, output2, output3)
[3 2 0 4 1]
[[0.92312991 0.49336370]
 [0.99248987 0.65806371]
 [0.73553443 0.73553443]]
[0.73553443 0.82625800 0.99248987 0.65806371 0.92312991]