Rate this Page
โ˜… โ˜… โ˜… โ˜… โ˜…

LocalResponseNorm#

class torch.nn.modules.normalization.LocalResponseNorm(size, alpha=0.0001, beta=0.75, k=1.0)[source]#

Applies local response normalization over an input signal.

The input signal is composed of several input planes, where channels occupy the second dimension. Applies normalization across channels.

bc=ac(k+ฮฑnโˆ‘cโ€ฒ=maxโก(0,cโˆ’n/2)minโก(Nโˆ’1,c+n/2)acโ€ฒ2)โˆ’ฮฒb_{c} = a_{c}\left(k + \frac{\alpha}{n} \sum_{c'=\max(0, c-n/2)}^{\min(N-1,c+n/2)}a_{c'}^2\right)^{-\beta}
Parameters:
  • size (int) โ€“ amount of neighbouring channels used for normalization

  • alpha (float) โ€“ multiplicative factor. Default: 0.0001

  • beta (float) โ€“ exponent. Default: 0.75

  • k (float) โ€“ additive factor. Default: 1

Shape:
  • Input: (N,C,โˆ—)(N, C, *)

  • Output: (N,C,โˆ—)(N, C, *) (same shape as input)

Examples:

>>> lrn = nn.LocalResponseNorm(2)
>>> signal_2d = torch.randn(32, 5, 24, 24)
>>> signal_4d = torch.randn(16, 5, 7, 7, 7, 7)
>>> output_2d = lrn(signal_2d)
>>> output_4d = lrn(signal_4d)
extra_repr()[source]#

Return the extra representation of the module.

forward(input)[source]#

Runs the forward pass.

Return type:

Tensor