AlexWang1900 glenn-jocher commited on
Commit
4b074d9
·
unverified ·
1 Parent(s): 5414e53

Funnel ReLU (FReLU) (#556)

Browse files

* fix #541 #542

* Update train.py

* Add Frelu

* Update activations.py

PEP8 and format updates for commonality with models.common.Conv()

* Update activations.py

Update case

* Update activations.py

Co-authored-by: Glenn Jocher <[email protected]>

Files changed (1) hide show
  1. utils/activations.py +13 -0
utils/activations.py CHANGED
@@ -61,3 +61,16 @@ class Mish(nn.Module): # https://github.com/digantamisra98/Mish
61
  @staticmethod
62
  def forward(x):
63
  return x * F.softplus(x).tanh()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  @staticmethod
62
  def forward(x):
63
  return x * F.softplus(x).tanh()
64
+
65
+
66
+ # FReLU https://arxiv.org/abs/2007.11824 --------------------------------------
67
+ class FReLU(nn.Module):
68
+ def __init__(self, c1, k=3): # ch_in, kernel
69
+ super().__init()__()
70
+ self.conv = nn.Conv2d(c1, c1, k, 1, 1, groups=c1)
71
+ self.bn = nn.BatchNorm2d(c1)
72
+
73
+ @staticmethod
74
+ def forward(self, x):
75
+ return torch.max(x, self.bn(self.conv(x)))
76
+