mindspore/docs/api/api_python/ops/mindspore.ops.UniformCandid...

31 lines
2.2 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.UniformCandidateSampler
======================================
.. py:class:: mindspore.ops.UniformCandidateSampler(num_true, num_sampled, unique, range_max, seed=0, remove_accidental_hits=False)
使用均匀分布对一组类别进行采样。
此函数使用均匀分布,从[0, range_max-1]中采样一组类sampled_candidates。如果 `unique```True`` ,则候选采样没有重复;如果 `unique```False`` ,则有重复。
更多参考详见 :func:`mindspore.ops.uniform_candidate_sampler`
.. warning::
- Ascend后端不支持随机数重现功能 `seed` 参数不起作用。
- Ascend后端暂不支持动态shape场景。
参数:
- **num_true** (int) - 每个训练样本的目标类数。
- **num_sampled** (int) - 随机采样的类数。 `sampled_candidates` 的shape将为 `num_sampled` 。如果 `unique```True`` ,则 `num_sampled` 必须小于或等于 `range_max`
- **unique** (bool) - 表示一个batch中的所有采样类是否唯一。
- **range_max** (int) - 可能的类数,该值必须是非负的。
- **seed** (int可选) - 随机种子,该值必须是非负的。如果 `seed` 的值为 ``0`` ,则 `seed` 的值将被随机生成的值替换。默认值: ``0``
- **remove_accidental_hits** (bool可选) - 表示是否移除accidental hit。accidental hit表示其中一个 `true_classes` 目标类匹配 `sampled_candidates` 采样类之一,设置为 ``True`` 表示移除等于目标类的采样类。默认值: ``False``
输入:
- **true_classes** (Tensor) - 输入Tensor目标类其shape为 :math:`(batch\_size, num\_true)`。 其元素值范围需要在 :math:`[0, range\_max)`
输出:
- **sampled_candidates** (Tensor) - 候选采样与目标类之间不存在联系其shape为 :math:`(num\_sampled, )`
- **true_expected_count** (Tensor) - 在每组目标类的采样分布下的预期计数其shape为 :math:`(batch\_size, num\_true)`
- **sampled_expected_count** (Tensor) - 每个候选采样分布下的预期计数其shape为 :math:`(num\_sampled, )`