| 90 | |
| 91 | |
| 92 | class FeedForward(nn.Module): |
| 93 | def __init__(self, dim, dim_out=None, mult=4, glu=False, dropout=0.0): |
| 94 | super().__init__() |
| 95 | inner_dim = int(dim * mult) |
| 96 | dim_out = default(dim_out, dim) |
| 97 | project_in = nn.Sequential(nn.Linear(dim, inner_dim), nn.GELU()) if not glu else GEGLU(dim, inner_dim) |
| 98 | |
| 99 | self.net = nn.Sequential(project_in, nn.Dropout(dropout), nn.Linear(inner_dim, dim_out)) |
| 100 | |
| 101 | def forward(self, x): |
| 102 | return self.net(x) |
| 103 | |
| 104 | |
| 105 | def zero_module(module): |