(self, hidden_dim)
| 97 | class MLPBlock(nn.Module): |
| 98 | |
| 99 | def __init__(self, hidden_dim): |
| 100 | super(MLPBlock, self).__init__() |
| 101 | self.gate_proj = nn.Linear(hidden_dim, hidden_dim, bias=False) |
| 102 | self.up_proj = nn.Linear(hidden_dim, hidden_dim, bias=False) |
| 103 | self.down_proj = nn.Linear(hidden_dim, hidden_dim, bias=False) |
| 104 | self.act_fn = nn.GELU() |
| 105 | |
| 106 | def forward(self, x): |
| 107 | return self.down_proj(self.act_fn(self.gate_proj(x)) * self.up_proj(x)) |