MCPcopy Create free account
hub / github.com/CompVis/diff2flow / __init__

Method __init__

diff2flow/models/unet/attention.py:144–159  ·  view source on GitHub ↗
(self, query_dim, context_dim=None, heads=8, dim_head=64, dropout=0.)

Source from the content-addressed store, hash-verified

142
143class CrossAttention(nn.Module):
144 def __init__(self, query_dim, context_dim=None, heads=8, dim_head=64, dropout=0.):
145 super().__init__()
146 inner_dim = dim_head * heads
147 context_dim = default(context_dim, query_dim)
148
149 self.scale = dim_head ** -0.5
150 self.heads = heads
151
152 self.to_q = nn.Linear(query_dim, inner_dim, bias=False)
153 self.to_k = nn.Linear(context_dim, inner_dim, bias=False)
154 self.to_v = nn.Linear(context_dim, inner_dim, bias=False)
155
156 self.to_out = nn.Sequential(
157 nn.Linear(inner_dim, query_dim),
158 nn.Dropout(dropout)
159 )
160
161 def forward(self, x, context=None, mask=None):
162 h = self.heads

Callers

nothing calls this directly

Calls 2

defaultFunction · 0.70
__init__Method · 0.45

Tested by

no test coverage detected