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.cell.Transition

View Source On Gitee
class mindsponge.cell.Transition(num_intermediate_factor, input_dim, batch_size=None, slice_num=0)[source]

This is 2-layer MLP where the intermediate layer expands number of channels of the input by a factor(num_intermediate_factor).

Transition(act)=Linear(Linear(act))
Parameters
  • num_intermediate_factor (float) – The expand factor of intermediate output channels compared to the input.

  • input_dim (int) – The channels of the input.

  • batch_size (int) – The batch size of parameters in Transition, used in while control flow. Default: "None".

  • slice_num (int) – The slice num used in transition layer when the memory is overflow. Default: 0.

Inputs:
  • act (Tensor) - The input with channels equal to input_dim, shape is (…, input_dim).

  • index (Tensor) - The index of while loop, only used in case of while control flow. Default: "None".

  • mask (Tensor) - The mask of act when to do layernorm with shape (32,inputdim), Default: "None".

Outputs:

Tensor, the float tensor of the output of the layer with shape (…, input_dim).

Supported Platforms:

Ascend GPU

Examples

>>> import numpy as np
>>> from mindsponge.cell import Transition
>>> from mindspore import dtype as mstype
>>> from mindspore import Tensor
>>> model = Transition(num_intermediate_factor=4, input_dim=128)
>>> input = Tensor(np.ones((32, 128, 128)), mstype.float32)
>>> output= model(input)
>>> print(output.shape)
(32, 128, 128)