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.

PR

Just a small problem.

I can fix it online!

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.BalancedMSE

View Source On Gitee
class mindsponge.metrics.BalancedMSE(first_break, last_break, num_bins, beta=0.99, reducer_flag=False)[source]

Balanced MSE error Compute Balanced MSE error between the prediction and the ground truth to solve unbalanced labels in regression task.

Reference:

Ren, Jiawei, et al. 'Balanced MSE for Imbalanced Visual Regression' .

L=logN(y;ypred ,σnoise 2I)+logi=1Nptrain (y(i))N(y(i);ypred ,σnoise 2I)
Parameters
  • first_break (float) – The begin value of bin.

  • last_break (float) – The end value of bin.

  • num_bins (int) – The bin numbers.

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

  • 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,ndim).

Supported Platforms:

Ascend GPU

Examples

>>> import numpy as np
>>> from mindsponge.metrics import BalancedMSE
>>> from mindspore import Tensor
>>> net = BalancedMSE(0, 1, 20)
>>> 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, 10)