Skip to content
Merged
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
11 changes: 4 additions & 7 deletions deepmd/pt/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,10 @@ def silu_grad(x):
self.const = float(silu(threshold))

def forward(self, x: torch.Tensor) -> torch.Tensor:
silu_part = F.silu(x)
mask = x >= self.threshold
if torch.any(mask):
tanh_part = torch.tanh(self.slope * (x - self.threshold)) + self.const
return torch.where(x < self.threshold, silu_part, tanh_part)
else:
return silu_part
sig = torch.sigmoid(x)
silu = x * sig
tanh = torch.tanh(self.slope * (x - self.threshold)) + self.const
return torch.where(x >= self.threshold, tanh, silu)


class ActivationFn(torch.nn.Module):
Expand Down
Loading