| 104 | |
| 105 | |
| 106 | class Mlp(nn.Module): |
| 107 | |
| 108 | def __init__( |
| 109 | self, |
| 110 | in_features, |
| 111 | hidden_features=None, |
| 112 | out_features=None, |
| 113 | act_layer=nn.GELU, |
| 114 | drop=0.0, |
| 115 | ): |
| 116 | super().__init__() |
| 117 | out_features = out_features or in_features |
| 118 | hidden_features = hidden_features or in_features |
| 119 | self.fc1 = nn.Linear(in_features, hidden_features) |
| 120 | self.act = act_layer() |
| 121 | self.fc2 = nn.Linear(hidden_features, out_features) |
| 122 | self.drop = nn.Dropout(drop) |
| 123 | |
| 124 | def forward(self, x): |
| 125 | x = self.fc1(x) |
| 126 | x = self.act(x) |
| 127 | x = self.drop(x) |
| 128 | x = self.fc2(x) |
| 129 | x = self.drop(x) |
| 130 | return x |
| 131 | |
| 132 | |
| 133 | class Attention(nn.Module): |
no outgoing calls
no test coverage detected