Softmax2d

classtorch.nn.Softmax2d(*args, **kwargs)[源代码]

对每个空间位置上的特征应用SoftMax函数。

当给定一个通道数 x 高度 x 宽度的图像时,它会对每个位置$(c, h_i, w_j)$应用Softmax函数。

形状:
  • 输入:$(N, C, H, W)$$(C, H, W)$

  • 输出: $(N, C, H, W)$$(C, H, W)$(与输入的形状相同)

返回值

一个与输入具有相同维度和形状的张量,其值范围在 [0, 1] 之间

返回类型

无内容

示例:

>>> m = nn.Softmax2d()
>>> # you softmax over the 2nd dimension
>>> input = torch.randn(2, 3, 12, 13)
>>> output = m(input)
本页目录