(
self,
spacial_dim: int,
embed_dim: int,
num_heads_channels: int,
output_dim: int = None,
)
| 96 | """ |
| 97 | |
| 98 | def __init__( |
| 99 | self, |
| 100 | spacial_dim: int, |
| 101 | embed_dim: int, |
| 102 | num_heads_channels: int, |
| 103 | output_dim: int = None, |
| 104 | ): |
| 105 | super().__init__() |
| 106 | self.positional_embedding = nn.Parameter( |
| 107 | th.randn(embed_dim, spacial_dim ** 2 + 1) / embed_dim ** 0.5 |
| 108 | ) |
| 109 | self.qkv_proj = conv_nd(1, embed_dim, 3 * embed_dim, 1) |
| 110 | self.c_proj = conv_nd(1, embed_dim, output_dim or embed_dim, 1) |
| 111 | self.num_heads = embed_dim // num_heads_channels |
| 112 | self.attention = QKVAttention(self.num_heads) |
| 113 | |
| 114 | def forward(self, x): |
| 115 | b, c, *_spatial = x.shape |
nothing calls this directly
no test coverage detected