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

35 lines
1.7 KiB
ReStructuredText
Raw 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。
**参数:**
- **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。
**异常:**
- **TypeError** - `num_true``num_sampled` 都不是int。
- **TypeError** - `unique` 不是bool。
- **TypeError** - `range_max``seed` 都不是int。
- **TypeError** - `true_classes` 不是Tensor。