MCPcopy Index your code
hub / github.com/VisionXLab/OF-Diff / __init__

Method __init__

ldm/modules/diffusionmodules/openaimodel.py:39–51  ·  view source on GitHub ↗
(
        self,
        spacial_dim: int,
        embed_dim: int,
        num_heads_channels: int,
        output_dim: int = None,
    )

Source from the content-addressed store, hash-verified

37 """
38
39 def __init__(
40 self,
41 spacial_dim: int,
42 embed_dim: int,
43 num_heads_channels: int,
44 output_dim: int = None,
45 ):
46 super().__init__()
47 self.positional_embedding = nn.Parameter(th.randn(embed_dim, spacial_dim ** 2 + 1) / embed_dim ** 0.5)
48 self.qkv_proj = conv_nd(1, embed_dim, 3 * embed_dim, 1)
49 self.c_proj = conv_nd(1, embed_dim, output_dim or embed_dim, 1)
50 self.num_heads = embed_dim // num_heads_channels
51 self.attention = QKVAttention(self.num_heads)
52
53 def forward(self, x):
54 b, c, *_spatial = x.shape

Callers

nothing calls this directly

Calls 3

conv_ndFunction · 0.90
QKVAttentionClass · 0.85
__init__Method · 0.45

Tested by

no test coverage detected