(self, dim, dim_ffn, dropout=0.1)
| 92 | class T5FeedForward(nn.Module): |
| 93 | |
| 94 | def __init__(self, dim, dim_ffn, dropout=0.1): |
| 95 | super(T5FeedForward, self).__init__() |
| 96 | self.dim = dim |
| 97 | self.dim_ffn = dim_ffn |
| 98 | |
| 99 | # layers |
| 100 | self.gate = nn.Sequential(nn.Linear(dim, dim_ffn, bias=False), GELU()) |
| 101 | self.fc1 = nn.Linear(dim, dim_ffn, bias=False) |
| 102 | self.fc2 = nn.Linear(dim_ffn, dim, bias=False) |
| 103 | self.dropout = nn.Dropout(dropout) |
| 104 | |
| 105 | def forward(self, x): |
| 106 | x = self.fc1(x) * self.gate(x) |