(
self,
embedding_dim: int,
num_heads: int,
causal: bool,
dropout: float,
bias: bool = True,
mlp_expansion: int = 4,
)
| 221 | """ |
| 222 | |
| 223 | def __init__( |
| 224 | self, |
| 225 | embedding_dim: int, |
| 226 | num_heads: int, |
| 227 | causal: bool, |
| 228 | dropout: float, |
| 229 | bias: bool = True, |
| 230 | mlp_expansion: int = 4, |
| 231 | ): |
| 232 | super().__init__() |
| 233 | |
| 234 | self.layernorm1 = LayerNorm(embedding_dim, bias=bias) |
| 235 | self.attention = SelfAttention( |
| 236 | embedding_dim, num_heads, bias=bias, dropout=dropout, causal=causal |
| 237 | ) |
| 238 | self.layernorm2 = LayerNorm(embedding_dim, bias=bias) |
| 239 | |
| 240 | hidden_dim = mlp_expansion * embedding_dim |
| 241 | self.mlp = MLP(embedding_dim, hidden_dim, nn.GELU(), dropout=dropout, bias=bias) |
| 242 | |
| 243 | def forward(self, x): |
| 244 | x = x + self.attention(self.layernorm1(x)) |
nothing calls this directly
no test coverage detected