(self, dim, depth, heads, dim_head, mlp_dim, dropout = 0.)
| 78 | |
| 79 | class Transformer(nn.Module): |
| 80 | def __init__(self, dim, depth, heads, dim_head, mlp_dim, dropout = 0.): |
| 81 | super().__init__() |
| 82 | self.layers = nn.ModuleList([]) |
| 83 | for _ in range(depth): |
| 84 | self.layers.append(nn.ModuleList([ |
| 85 | Attention(dim, heads = heads, dim_head = dim_head, dropout = dropout), |
| 86 | FeedForward(dim, mlp_dim, dropout = dropout) |
| 87 | ])) |
| 88 | def forward(self, x): |
| 89 | for attn, ff in self.layers: |
| 90 | x = attn(x) + x |
nothing calls this directly
no test coverage detected