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

Class Mlp

semantic_sam/backbone/focal_dw.py:24–42  ·  view source on GitHub ↗

Multilayer perceptron.

Source from the content-addressed store, hash-verified

22logger = logging.getLogger(__name__)
23
24class Mlp(nn.Module):
25 """ Multilayer perceptron."""
26
27 def __init__(self, in_features, hidden_features=None, out_features=None, act_layer=nn.GELU, drop=0.):
28 super().__init__()
29 out_features = out_features or in_features
30 hidden_features = hidden_features or in_features
31 self.fc1 = nn.Linear(in_features, hidden_features)
32 self.act = act_layer()
33 self.fc2 = nn.Linear(hidden_features, out_features)
34 self.drop = nn.Dropout(drop)
35
36 def forward(self, x):
37 x = self.fc1(x)
38 x = self.act(x)
39 x = self.drop(x)
40 x = self.fc2(x)
41 x = self.drop(x)
42 return x
43
44class FocalModulation(nn.Module):
45 """ Focal Modulation

Callers 1

__init__Method · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected