Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions torch/nn/modules/normalization.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ def __init__(
self.alpha = alpha
self.beta = beta
self.k = k
if k <= 0 and alpha <= 0 and beta != 0:
raise ValueError(
f"LocalResponseNorm: k and alpha cannot both be non-positive "
f"when beta is non-zero; "
f"got k={k}, alpha={alpha}, beta={beta}. "
f"The denominator k + (alpha/size) * sum(x^2) would collapse to zero "
f"and 0^(-beta) = inf."
)

def forward(self, input: Tensor) -> Tensor:
"""
Expand Down