MCPcopy Create free account
hub / github.com/dome272/Diffusion-Models-pytorch / DoubleConv

Class DoubleConv

modules.py:58–76  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

56
57
58class DoubleConv(nn.Module):
59 def __init__(self, in_channels, out_channels, mid_channels=None, residual=False):
60 super().__init__()
61 self.residual = residual
62 if not mid_channels:
63 mid_channels = out_channels
64 self.double_conv = nn.Sequential(
65 nn.Conv2d(in_channels, mid_channels, kernel_size=3, padding=1, bias=False),
66 nn.GroupNorm(1, mid_channels),
67 nn.GELU(),
68 nn.Conv2d(mid_channels, out_channels, kernel_size=3, padding=1, bias=False),
69 nn.GroupNorm(1, out_channels),
70 )
71
72 def forward(self, x):
73 if self.residual:
74 return F.gelu(x + self.double_conv(x))
75 else:
76 return self.double_conv(x)
77
78
79class Down(nn.Module):

Callers 4

__init__Method · 0.85
__init__Method · 0.85
__init__Method · 0.85
__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected