MCPcopy Create free account
hub / github.com/MotrixLab/AiOS / Mlp

Class Mlp

models/aios/backbones/swin_transformer.py:10–32  ·  view source on GitHub ↗

Multilayer perceptron.

Source from the content-addressed store, hash-verified

8
9
10class Mlp(nn.Module):
11 """Multilayer perceptron."""
12 def __init__(self,
13 in_features,
14 hidden_features=None,
15 out_features=None,
16 act_layer=nn.GELU,
17 drop=0.):
18 super().__init__()
19 out_features = out_features or in_features
20 hidden_features = hidden_features or in_features
21 self.fc1 = nn.Linear(in_features, hidden_features)
22 self.act = act_layer()
23 self.fc2 = nn.Linear(hidden_features, out_features)
24 self.drop = nn.Dropout(drop)
25
26 def forward(self, x):
27 x = self.fc1(x)
28 x = self.act(x)
29 x = self.drop(x)
30 x = self.fc2(x)
31 x = self.drop(x)
32 return x
33
34
35def window_partition(x, window_size):

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected