評價此頁

Softmax2d#

class torch.nn.modules.activation.Softmax2d(*args, **kwargs)[source]#

對每個空間位置應用特徵上的 SoftMax。

當給定一個 Channels x Height x Width 格式的影像時,它將對每個位置 (Channels,hi,wj)(Channels, h_i, w_j) 應用 Softmax

形狀
  • 輸入: (N,C,H,W)(N, C, H, W)(C,H,W)(C, H, W)

  • 輸出: (N,C,H,W)(N, C, H, W)(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)
forward(input)[source]#

執行前向傳播。

返回型別

張量