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.

mindsponge.metrics.MultiClassFocal

class mindsponge.metrics.MultiClassFocal(num_class, beta=0.99, gamma=2.0, e=0.1, neighbors=2, not_focal=False, reducer_flag=False)[source]

Focal error for multi-class classifications. Compute the multiple classes focal error between prediction and the ground truth target. Reference: Lin, Tsung-Yi, et al. ‘Focal loss for dense object detection’ .

Parameters
  • num_class (int) – The class numbers.

  • beta (float) – The moving average coefficient, default: 0.99.

  • gamma (float) – The hyperparameters, default: 2.0.

  • e (float) – The proportion of focal loss, default: 0.1.

  • neighbors (int) – The neighbors to be mask in the target, default 2.

  • not_focal (bool) – Whether focal loss, default: “False”.

  • reducer_flag (bool) – Whether to aggregate the label values of multiple devices, default: “False”.

Inputs:
  • prediction (Tensor) - Predict values, shape is (batch_size,ndim).

  • target (Tensor) - Label values, shape is (batch_size,ndim).

Outputs:

Tensor, shape is (batch_size,).

Supported Platforms:

Ascend GPU

Examples

>>> import numpy as np
>>> from mindspore import Tensor
>>> from mindsponge.metrics import MultiClassFocal
>>> net = MultiClassFocal(10)
>>> prediction = Tensor(np.random.randn(32, 10).astype(np.float32))
>>> target = Tensor(np.random.randn(32, 10).astype(np.float32))
>>> out = net(prediction, target)
>>> print(out.shape)
(32,)