Method
__init__
(self, dim, heads=4, dim_head=32)
Source from the content-addressed store, hash-verified
| 133 | |
| 134 | class LinearAttention(nn.Module): |
| 135 | def __init__(self, dim, heads=4, dim_head=32): |
| 136 | super().__init__() |
| 137 | self.heads = heads |
| 138 | hidden_dim = dim_head * heads |
| 139 | self.to_qkv = nn.Conv2d(dim, hidden_dim * 3, 1, bias=False) |
| 140 | self.to_out = nn.Conv2d(hidden_dim, dim, 1) |
| 141 | |
| 142 | def forward(self, x): |
| 143 | b, c, h, w = x.shape |
Callers
nothing calls this directly
Tested by
no test coverage detected