Document feedback

Question document fragment

When a question document fragment contains a formula, it is displayed as a space.

Submission type
issue

It's a little complicated...

I'd like to ask someone.

Please select the submission type

Problem type
Specifications and Common Mistakes

- Specifications and Common Mistakes:

- Misspellings or punctuation mistakes,incorrect formulas, abnormal display.

- Incorrect links, empty cells, or wrong formats.

- Chinese characters in English context.

- Minor inconsistencies between the UI and descriptions.

- Low writing fluency that does not affect understanding.

- Incorrect version numbers, including software package names and version numbers on the UI.

Usability

- Usability:

- Incorrect or missing key steps.

- Missing main function descriptions, keyword explanation, necessary prerequisites, or precautions.

- Ambiguous descriptions, unclear reference, or contradictory context.

- Unclear logic, such as missing classifications, items, and steps.

Correctness

- Correctness:

- Technical principles, function descriptions, supported platforms, parameter types, or exceptions inconsistent with that of software implementation.

- Incorrect schematic or architecture diagrams.

- Incorrect commands or command parameters.

- Incorrect code.

- Commands inconsistent with the functions.

- Wrong screenshots.

- Sample code running error, or running results inconsistent with the expectation.

Risk Warnings

- Risk Warnings:

- Lack of risk warnings for operations that may damage the system or important data.

Content Compliance

- Content Compliance:

- Contents that may violate applicable laws and regulations or geo-cultural context-sensitive words and expressions.

- Copyright infringement.

Please select the type of question

Problem description

Describe the bug so that we can quickly locate the problem.

mindspore.ops.LogUniformCandidateSampler

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

Generates random labels with a log-uniform distribution for sampled_candidates.

Randomly samples a tensor of sampled classes from the range of integers [0, range_max).

Refer to mindspore.ops.log_uniform_candidate_sampler() for more details.

Warning

The Ascend backend does not support the reproducibility of random numbers, so the seed parameter has no effect.

Parameters
  • num_true (int, optional) – The number of target classes per training example. Default: 1 .

  • num_sampled (int, optional) – The number of classes to randomly sample. Default: 5 .

  • unique (bool, optional) – Determines whether sample with rejection. If unique is True , all sampled classes in a batch are unique. Default: True .

  • range_max (int, optional) – The number of possible classes. When unique is True , range_max must be greater than or equal to num_sampled. Default: 5 .

  • seed (int, optional) – Random seed, must be non-negative. Default: 0 .

Inputs:
  • true_classes (Tensor) - The target classes. With data type of int64 and shape (batch_size,num_true) .

Outputs:

Tuple of 3 Tensors.

  • sampled_candidates (Tensor) - A Tensor with shape (num_sampled,) and the same type as true_classes.

  • true_expected_count (Tensor) - A Tensor with the same shape as true_classes and type float32.

  • sampled_expected_count (Tensor) - A Tensor with the same shape as sampled_candidates and type float32.

Supported Platforms:

Ascend CPU

Examples

>>> import numpy as np
>>> from mindspore import Tensor, ops
>>> 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]