Update functions.py

This commit is contained in:
Jinwoo Park (Curt)
2025-03-18 09:49:59 +09:00
committed by GitHub
parent 765fb01c09
commit c016ddd473
+4 -4
View File
@@ -41,9 +41,9 @@ class InPlaceABN(autograd.Function):
if ctx.activation == ACT_LEAKY_RELU:
x_norm = torch.where(x_norm > 0, x_norm, x_norm * ctx.slope)
elif ctx.activation == ACT_RELU:
x_norm = torch.where(x > 0, x, torch.zeros_like(x))
x_norm = torch.where(x_norm > 0, x_norm, torch.zeros_like(x_norm))
elif ctx.activation == ACT_ELU:
x_norm = torch.where(x > 0, x, (torch.exp(x) - 1))
x_norm = torch.where(x_norm > 0, x_norm, (torch.exp(x) - 1))
ctx.save_for_backward(x_norm, var, weight, bias)
ctx.mark_non_differentiable(running_mean, running_var)
@@ -134,9 +134,9 @@ class InPlaceABNSync(autograd.Function):
if ctx.activation == ACT_LEAKY_RELU:
x_norm = torch.where(x_norm > 0, x_norm, x_norm * ctx.slope)
elif ctx.activation == ACT_RELU:
x_norm = torch.where(x > 0, x, torch.zeros_like(x))
x_norm = torch.where(x_norm > 0, x_norm, torch.zeros_like(x_norm))
elif ctx.activation == ACT_ELU:
x_norm = torch.where(x > 0, x, (torch.exp(x) - 1))
x_norm = torch.where(x_norm > 0, x_norm, (torch.exp(x) - 1))
ctx.save_for_backward(x_norm, var, weight, bias)
ctx.mark_non_differentiable(running_mean, running_var)