Method
__init__
(
self,
in_features,
hidden_features=None,
out_features=None,
act_layer=nn.GELU,
drop_rate=0.0,
)
Source from the content-addressed store, hash-verified
| 6 | |
| 7 | class Mlp(nn.Module): |
| 8 | def __init__( |
| 9 | self, |
| 10 | in_features, |
| 11 | hidden_features=None, |
| 12 | out_features=None, |
| 13 | act_layer=nn.GELU, |
| 14 | drop_rate=0.0, |
| 15 | ): |
| 16 | super().__init__() |
| 17 | self.drop_rate = drop_rate |
| 18 | out_features = out_features or in_features |
| 19 | hidden_features = hidden_features or in_features |
| 20 | self.fc1 = nn.Linear(in_features, hidden_features) |
| 21 | self.act = act_layer() |
| 22 | self.fc2 = nn.Linear(hidden_features, out_features) |
| 23 | if self.drop_rate > 0.0: |
| 24 | self.drop = nn.Dropout(drop_rate) |
| 25 | |
| 26 | def forward(self, x): |
| 27 | x = self.fc1(x) |
Tested by
no test coverage detected