This commit is contained in:
Glenn Jocher 2019-11-17 12:21:59 -08:00
parent eb32fca702
commit bb936f758a
1 changed files with 2 additions and 3 deletions

View File

@ -118,16 +118,15 @@ class Swish(nn.Module):
super(Swish, self).__init__() super(Swish, self).__init__()
def forward(self, x): def forward(self, x):
return x * torch.sigmoid(x) return x.mul_(torch.sigmoid(x))
class Mish(nn.Module): # https://github.com/digantamisra98/Mish class Mish(nn.Module): # https://github.com/digantamisra98/Mish
# Applies the mish function element-wise: mish(x) = x * tanh(softplus(x)) = x * tanh(ln(1 + exp(x)))
def __init__(self): def __init__(self):
super().__init__() super().__init__()
def forward(self, x): def forward(self, x):
return x * torch.tanh(F.softplus(x)) return x.mul_(F.softplus(x).tanh())
class YOLOLayer(nn.Module): class YOLOLayer(nn.Module):