MCPcopy Create free account
hub / github.com/ChunmingHe/WS-SAM / FeedForward

Class FeedForward

lib/VIT/decoder/decoder_p.py:96–112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

94 weight_init(self)
95
96class FeedForward(nn.Module):
97 def __init__(self, dim, ffn_expansion_factor, bias):
98 super(FeedForward, self).__init__()
99 hidden_features = int(dim*ffn_expansion_factor)
100 self.project_in = nn.Conv2d(dim, hidden_features*2, kernel_size=1, bias=bias)
101 self.dwconv = nn.Conv2d(hidden_features*2, hidden_features*2, kernel_size=3, stride=1, padding=1, groups=hidden_features*2, bias=bias)
102 self.project_out = nn.Conv2d(hidden_features, dim, kernel_size=1, bias=bias)
103
104 def forward(self, x):
105 x = self.project_in(x)
106 x1, x2 = self.dwconv(x).chunk(2, dim=1)
107 x = F.gelu(x1) * x2
108 x = self.project_out(x)
109 return x
110
111 def initialize(self):
112 weight_init(self)
113
114class Attention(nn.Module):
115 def __init__(self, dim, num_heads, bias,mode):

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected