MCPcopy Create free account
hub / github.com/OpenDriveLab/ReSim / MLP

Class MLP

SwissArmyTransformer/sat/model/official/yolos_model.py:21–33  ·  view source on GitHub ↗

Very simple multi-layer perceptron (also called FFN)

Source from the content-addressed store, hash-verified

19 self.transformer.word_embeddings.weight.data[:old_weight.shape[0]] = old_weight
20
21class MLP(nn.Module):
22 """ Very simple multi-layer perceptron (also called FFN)"""
23
24 def __init__(self, input_dim, hidden_dim, output_dim, num_layers):
25 super().__init__()
26 self.num_layers = num_layers
27 h = [hidden_dim] * (num_layers - 1)
28 self.layers = nn.ModuleList(nn.Linear(n, k) for n, k in zip([input_dim] + h, h + [output_dim]))
29
30 def forward(self, x):
31 for i, layer in enumerate(self.layers):
32 x = F.relu(layer(x)) if i < self.num_layers - 1 else layer(x)
33 return x
34
35class DetHeadMixin(BaseMixin):
36 def __init__(self, args):

Callers 1

__init__Method · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected