Method
__init__
(self, dim, heads=4, dim_head=32)
Source from the content-addressed store, hash-verified
| 117 | |
| 118 | class LinearAttention(nn.Module): |
| 119 | def __init__(self, dim, heads=4, dim_head=32): |
| 120 | super().__init__() |
| 121 | self.heads = heads |
| 122 | hidden_dim = dim_head * heads |
| 123 | self.to_qkv = nn.Conv2d(dim, hidden_dim * 3, 1, bias=False) |
| 124 | self.to_out = nn.Conv2d(hidden_dim, dim, 1) |
| 125 | |
| 126 | def forward(self, x): |
| 127 | b, c, h, w = x.shape |
Callers
nothing calls this directly
Tested by
no test coverage detected