MCPcopy Create free account
hub / github.com/UX-Decoder/Semantic-SAM / Mlp

Class Mlp

semantic_sam/backbone/swin.py:26–46  ·  view source on GitHub ↗

Multilayer perceptron.

Source from the content-addressed store, hash-verified

24
25
26class Mlp(nn.Module):
27 """Multilayer perceptron."""
28
29 def __init__(
30 self, in_features, hidden_features=None, out_features=None, act_layer=nn.GELU, drop=0.0
31 ):
32 super().__init__()
33 out_features = out_features or in_features
34 hidden_features = hidden_features or in_features
35 self.fc1 = nn.Linear(in_features, hidden_features)
36 self.act = act_layer()
37 self.fc2 = nn.Linear(hidden_features, out_features)
38 self.drop = nn.Dropout(drop)
39
40 def forward(self, x):
41 x = self.fc1(x)
42 x = self.act(x)
43 x = self.drop(x)
44 x = self.fc2(x)
45 x = self.drop(x)
46 return x
47
48
49def window_partition(x, window_size):

Callers 1

__init__Method · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected