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

View Source On Gitee
class mindsponge.cell.OuterProductMean(num_outer_channel, act_dim, num_output_channel, batch_size=None, slice_num=0)[source]

Computing the correlation of the input tensor along its second dimension, the computed correlation could be used to update the correlation features(e.g. the Pair representation).

OuterProductMean(act)=Linear(flatten(mean(actact)))
Parameters
  • num_outer_channel (float) – The last dimension size of intermediate layer in OuterProductMean.

  • act_dim (int) – The last dimension size of the input act.

  • num_output_channel (int) – The last dimension size of output.

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

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

Inputs:
  • act (Tensor) - The input tensor with shape (dim1,dim2,act_dim).

  • mask (Tensor) - The mask for OuterProductMean with shape (dim1,dim2).

  • mask_norm (Tensor) - Squared L2-norm along the first dimension of mask, pre-computed to avoid re-computing, its shape is (dim2,dim2,1).

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

Outputs:

Tensor, the float tensor of the output of OuterProductMean layer with shape (dim2,dim2,num_output_channel).

Supported Platforms:

Ascend GPU

Examples

>>> import numpy as np
>>> from mindsponge.cell import OuterProductMean
>>> from mindspore import dtype as mstype
>>> from mindspore import Tensor
>>> from mindspore.ops import operations as P
>>> model = OuterProductMean(num_outer_channel=32, act_dim=128, num_output_channel=256)
>>> act = Tensor(np.ones((32, 64, 128)), mstype.float32)
>>> mask = Tensor(np.ones((32, 64)), mstype.float32)
>>> mask_norm = P.ExpandDims()(P.MatMul(transpose_a=True)(mask, mask), -1)
>>> output= model(act, mask, mask_norm)
>>> print(output.shape)
(64, 64, 256)