Funnel ReLU (FReLU) (#556)
Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
This commit is contained in:
parent
4b074d9d9d
commit
131782a2aa
|
|
@ -1,7 +1,6 @@
|
||||||
import torch
|
import torch
|
||||||
import torch.nn as nn
|
import torch.nn as nn
|
||||||
import torch.nn.functional as F
|
import torch.nn.functional as F
|
||||||
import torch.nn as nn
|
|
||||||
|
|
||||||
|
|
||||||
# Swish ------------------------------------------------------------------------
|
# Swish ------------------------------------------------------------------------
|
||||||
|
|
@ -61,16 +60,15 @@ class Mish(nn.Module): # https://github.com/digantamisra98/Mish
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def forward(x):
|
def forward(x):
|
||||||
return x * F.softplus(x).tanh()
|
return x * F.softplus(x).tanh()
|
||||||
|
|
||||||
|
|
||||||
# FReLU https://arxiv.org/abs/2007.11824 --------------------------------------
|
# FReLU https://arxiv.org/abs/2007.11824 --------------------------------------
|
||||||
class FReLU(nn.Module):
|
class FReLU(nn.Module):
|
||||||
def __init__(self, c1, k=3): # ch_in, kernel
|
def __init__(self, c1, k=3): # ch_in, kernel
|
||||||
super().__init()__()
|
super(FReLU, self).__init__()
|
||||||
self.conv = nn.Conv2d(c1, c1, k, 1, 1, groups=c1)
|
self.conv = nn.Conv2d(c1, c1, k, 1, 1, groups=c1)
|
||||||
self.bn = nn.BatchNorm2d(c1)
|
self.bn = nn.BatchNorm2d(c1)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def forward(self, x):
|
def forward(self, x):
|
||||||
return torch.max(x, self.bn(self.conv(x)))
|
return torch.max(x, self.bn(self.conv(x)))
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue