| 75 | |
| 76 | class FeedForward(nn.Module): |
| 77 | def __init__(self, embed_dim, hidden_dim, dropout=0.1, activation='gelu'): |
| 78 | super().__init__() |
| 79 | self.fc1 = nn.Linear(embed_dim, hidden_dim) |
| 80 | self.fc2 = nn.Linear(hidden_dim, embed_dim) |
| 81 | self.dropout = nn.Dropout(dropout) |
| 82 | |
| 83 | if activation == 'gelu': |
| 84 | self.activation = nn.GELU() |
| 85 | elif activation == 'relu': |
| 86 | self.activation = nn.ReLU() |
| 87 | elif activation == 'silu': |
| 88 | self.activation = nn.SiLU() |
| 89 | else: |
| 90 | self.activation = nn.GELU() |
| 91 | |
| 92 | def forward(self, x): |
| 93 | x = self.fc1(x) |