HardELiSH is a hard approximation of ELiSH that replaces its sigmoid function with the hard sigmoid : an activation function that achieves a similar effect at a lower computational cost.
The output range is
Activation Functions
Updated:
HardELiSH is a hard approximation of ELiSH that replaces its sigmoid function with the hard sigmoid : an activation function that achieves a similar effect at a lower computational cost.
The output range is
# PyTorch
import torch
import torch.nn as nn
class NN(nn.Module):
def __init__(self):
super().__init__()
def hard_sigmoid(self, x):
return torch.clamp((x + 1) / 2, min=0.0, max=1.0)
def hard_elish(self, x):
hs = self.hard_sigmoid(x)
return torch.where(x >= 0, x * hs, (torch.exp(x) - 1) * hs)
def forward(self, x):
x = self.hard_elish(x)
return x