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.mint.nn.BatchNorm1d

class mindspore.mint.nn.BatchNorm1d(num_features: int, eps=1e-5, momentum=0.1, affine=True, track_running_stats=True, dtype=None)[source]

Applies Batch Normalization over a 2D or 3D input as described in the paper Batch Normalization: Accelerating Deep Network Training by Reducing Internal Covariate Shift .

y=xmeanvariance+ϵγ+β

The mean and standard-deviation are calculated per-dimension over the mini-batches and γ and β are learnable parameter vectors of size C (where C is the number of features or channels of the input). By default, the elements of γ are set to 1 and the elements of β are set to 0.

Warning

This API does not support Dynamic Rank. This is an experimental API that is subject to change or deletion.

Parameters
  • num_features (int) – C from an expected input of shape (N,C,L).

  • eps (float, optional) – a value added to the denominator for numerical stability. Default: 1e-5 .

  • momentum (float, optional) – the value used for the running_mean and running_var computation. Can be set to None for cumulative moving average. Default: 0.1 .

  • affine (bool, optional) – a boolean value that when set to True, this cell has learnable affine parameters. Default: True .

  • track_running_stats (bool, optional) – a boolean value that when set to True, this cell tracks the running mean and variance, and when set to False, this cell does not track such statistics. And this cell always uses batch statistics in both training and eval modes. Default: True .

  • dtype (mindspore.dtype, optional) – Dtype of Parameters. Default: None .

Inputs:
  • input (Tensor) - The input with shape (N,C) or (N,C,L), where N means batch, C means the number of feature or the number of channel, and L is the length of sequence.

Outputs:

Tensor, has the same type and shape as input.

Raises
Supported Platforms:

Ascend

Examples

>>> import mindspore
>>> from mindspore import Tensor, mint
>>> input_x = mindspore.Tensor([[0.7, 0.5, 0.5, 0.6], [0.5, 0.4, 0.6, 0.9]])
>>> net = mint.nn.BatchNorm1d(4)
>>> output = net(input_x)
>>> print(output)
[[ 0.99950075 0.9980011 -0.9980068 -0.9997783]
 [-0.9995012 -0.99799967 0.9980068  0.9997778]]