mindspore/docs/api/api_python/ops/mindspore.ops.LogUniformCan...

31 lines
1.7 KiB
ReStructuredText
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

mindspore.ops.LogUniformCandidateSampler
=========================================
.. py: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。
更多参考详见 :func:`mindspore.ops.log_uniform_candidate_sampler`
.. warning::
Ascend后端不支持随机数重现功能 `seed` 参数不起作用。
参数:
- **num_true** (int可选) - 每个训练样本的目标类数。默认值: ``1``
- **num_sampled** (int可选) - 随机采样的类数。默认值: ``5``
- **unique** (bool可选) - 确认批处理中的所有采样类是否都是唯一的。如果 `unique```True`` ,则批处理中的所有采样类都唯一。默认值: ``True``
- **range_max** (int可选) - 可能的类数。当 `unique```True`` 时, `range_max` 必须大于或等于 `num_sampled` 。默认值: ``5``
- **seed** (int可选) - 随机种子,必须是非负数。默认值: ``0``
输入:
- **true_classes** (Tensor) - 目标类其数据类型为int64shape为 :math:`(batch\_size, num\_true)`
输出:
3个Tensor组成的元组。
- **sampled_candidates** (Tensor) - shape为 :math:`(num\_sampled,)` 且数据类型与 `true_classes` 相同的Tensor。
- **true_expected_count** (Tensor) - shape与 `true_classes` 相同且数据类型为float32的Tensor。
- **sampled_expected_count** (Tensor) - shape与 `sampled_candidates` 相同且数据类型为float32的Tensor。