MCPcopy Create free account
hub / github.com/PrathamLearnsToCode/paper2code / Upsample

Class Upsample

skills/paper2code/worked/ddpm/src/model.py:203–212  ·  view source on GitHub ↗

Spatial upsampling by factor 2. [FROM_OFFICIAL_CODE]

Source from the content-addressed store, hash-verified

201
202
203class Upsample(nn.Module):
204 """Spatial upsampling by factor 2. [FROM_OFFICIAL_CODE]"""
205
206 def __init__(self, channels: int):
207 super().__init__()
208 self.conv = nn.Conv2d(channels, channels, kernel_size=3, padding=1)
209
210 def forward(self, x: torch.Tensor) -> torch.Tensor:
211 x = F.interpolate(x, scale_factor=2, mode="nearest")
212 return self.conv(x) # (batch, C, H, W) -> (batch, C, 2H, 2W)
213
214
215# ---------------------------------------------------------------------------

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected