MCPcopy Create free account
hub / github.com/DPS2022/diffusion-posterior-sampling / forward

Method forward

guided_diffusion/unet.py:114–122  ·  view source on GitHub ↗
(self, x)

Source from the content-addressed store, hash-verified

112 self.attention = QKVAttention(self.num_heads)
113
114 def forward(self, x):
115 b, c, *_spatial = x.shape
116 x = x.reshape(b, c, -1) # NC(HW)
117 x = th.cat([x.mean(dim=-1, keepdim=True), x], dim=-1) # NC(HW+1)
118 x = x + self.positional_embedding[None, :, :].to(x.dtype) # NC(HW+1)
119 x = self.qkv_proj(x)
120 x = self.attention(x)
121 x = self.c_proj(x)
122 return x[:, :, 0]
123
124
125class TimestepBlock(nn.Module):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected