MCPcopy Create free account
hub / github.com/SooLab/CGFormer / Mlp

Class Mlp

model/backbone.py:12–30  ·  view source on GitHub ↗

Multilayer perceptron.

Source from the content-addressed store, hash-verified

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

Callers 1

__init__Method · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected