MCPcopy Create free account
hub / github.com/microsoft/Cream / Mlp

Class Mlp

TinyViT/models/tiny_vit.py:193–213  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

191
192
193class Mlp(nn.Module):
194 def __init__(self, in_features, hidden_features=None,
195 out_features=None, act_layer=nn.GELU, drop=0.):
196 super().__init__()
197 out_features = out_features or in_features
198 hidden_features = hidden_features or in_features
199 self.norm = nn.LayerNorm(in_features)
200 self.fc1 = nn.Linear(in_features, hidden_features)
201 self.fc2 = nn.Linear(hidden_features, out_features)
202 self.act = act_layer()
203 self.drop = nn.Dropout(drop)
204
205 def forward(self, x):
206 x = self.norm(x)
207
208 x = self.fc1(x)
209 x = self.act(x)
210 x = self.drop(x)
211 x = self.fc2(x)
212 x = self.drop(x)
213 return x
214
215
216class Attention(torch.nn.Module):

Callers 1

__init__Method · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected