| 14 | |
| 15 | |
| 16 | class Mlp(nn.Module): |
| 17 | |
| 18 | def __init__(self, in_features, hidden_features=None, out_features=None, act_layer=nn.GELU, drop=0.): |
| 19 | super().__init__() |
| 20 | out_features = out_features or in_features |
| 21 | hidden_features = hidden_features or in_features |
| 22 | self.fc1 = nn.Linear(in_features, hidden_features) |
| 23 | self.act = act_layer() |
| 24 | self.fc2 = nn.Linear(hidden_features, out_features) |
| 25 | self.drop = nn.Dropout(drop) |
| 26 | |
| 27 | def forward(self, x): |
| 28 | x = self.fc1(x) |
| 29 | x = self.act(x) |
| 30 | x = self.drop(x) |
| 31 | x = self.fc2(x) |
| 32 | x = self.drop(x) |
| 33 | return x |
| 34 | |
| 35 | def conv_layer(in_dim, out_dim, kernel_size=1, padding=0, stride=1): |
| 36 | return nn.Sequential( |