Table of Contents
Shortcuts

# Softmax2d

class torch.nn.Softmax2d(*args, **kwargs)

  Applies SoftMax over features to each spatial location.

  When given an image of `Channels x Height x Width`, it will apply Softmax to each location (C h a n n e l s,h i,w j)(Channels, h_i, w_j)(C hann e l s,h i​,w j​)

  Shape:

    - Input: (N,C,H,W)(N, C, H, W)(N,C,H,W) or (C,H,W)(C, H, W)(C,H,W).

    - Output: (N,C,H,W)(N, C, H, W)(N,C,H,W) or (C,H,W)(C, H, W)(C,H,W) (same shape as input)

  Returns:

    a Tensor of the same dimension and shape as the input with values in the range [0, 1]

  Return type:

    None

  Examples:

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

## Docs

Access comprehensive developer documentation for PyTorch

View Docs

## Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

## Resources

Find development resources and get your questions answered

View Resources

To analyze traffic and optimize your experience, we serve cookies on this site. By clicking or navigating, you agree to allow our usage of cookies. As the current maintainers of this site, Facebook’s Cookies Policy applies. Learn more, including about available controls: Cookies Policy.