mindspore.nn.Softmax2d
- class mindspore.nn.Softmax2d[source]
Softmax function applied to 2D features data.
Applies Softmax to each location \((c, h, w)\) with an input Tensor of shape \((C, H, W)\) .
- Inputs:
x (Tensor) - Tensor of shape \((N, C_{in}, H_{in}, W_{in})\) or \((C_{in}, H_{in}, W_{in})\).
- Outputs:
Tensor, which has the same type and shape as x with values in the range[0,1].
- Raises
TypeError – If dtype of x is neither float16 nor float32.
ValueError – If data_format is neither ‘NCHW’ nor ‘CHW’.
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> x = Tensor(np.array([[[[0.1, 0.2]], [[0.3, 0.4]], [[0.6, 0.5]]]]), mindspore.float32) >>> softmax2d = nn.Softmax2d() >>> output = softmax2d(x) >>> print(output) [[[[0.258, 0.28]], [[0.316, 0.342]], [[0.426, 0.378]]]