(
self,
spacial_dim: int,
embed_dim: int,
num_heads_channels: int,
output_dim: int = None,
)
| 61 | """ |
| 62 | |
| 63 | def __init__( |
| 64 | self, |
| 65 | spacial_dim: int, |
| 66 | embed_dim: int, |
| 67 | num_heads_channels: int, |
| 68 | output_dim: int = None, |
| 69 | ): |
| 70 | super().__init__() |
| 71 | self.positional_embedding = nn.Parameter(th.randn(embed_dim, spacial_dim ** 2 + 1) / embed_dim ** 0.5) |
| 72 | self.qkv_proj = conv_nd(1, embed_dim, 3 * embed_dim, 1) |
| 73 | self.c_proj = conv_nd(1, embed_dim, output_dim or embed_dim, 1) |
| 74 | self.num_heads = embed_dim // num_heads_channels |
| 75 | self.attention = QKVAttention(self.num_heads) |
| 76 | |
| 77 | def forward(self, x): |
| 78 | b, c, *_spatial = x.shape |
nothing calls this directly
no test coverage detected