MCPcopy
hub / github.com/ermongroup/ddim / __init__

Method __init__

models/diffusion.py:78–113  ·  view source on GitHub ↗
(self, *, in_channels, out_channels=None, conv_shortcut=False,
                 dropout, temb_channels=512)

Source from the content-addressed store, hash-verified

76
77class ResnetBlock(nn.Module):
78 def __init__(self, *, in_channels, out_channels=None, conv_shortcut=False,
79 dropout, temb_channels=512):
80 super().__init__()
81 self.in_channels = in_channels
82 out_channels = in_channels if out_channels is None else out_channels
83 self.out_channels = out_channels
84 self.use_conv_shortcut = conv_shortcut
85
86 self.norm1 = Normalize(in_channels)
87 self.conv1 = torch.nn.Conv2d(in_channels,
88 out_channels,
89 kernel_size=3,
90 stride=1,
91 padding=1)
92 self.temb_proj = torch.nn.Linear(temb_channels,
93 out_channels)
94 self.norm2 = Normalize(out_channels)
95 self.dropout = torch.nn.Dropout(dropout)
96 self.conv2 = torch.nn.Conv2d(out_channels,
97 out_channels,
98 kernel_size=3,
99 stride=1,
100 padding=1)
101 if self.in_channels != self.out_channels:
102 if self.use_conv_shortcut:
103 self.conv_shortcut = torch.nn.Conv2d(in_channels,
104 out_channels,
105 kernel_size=3,
106 stride=1,
107 padding=1)
108 else:
109 self.nin_shortcut = torch.nn.Conv2d(in_channels,
110 out_channels,
111 kernel_size=1,
112 stride=1,
113 padding=0)
114
115 def forward(self, x, temb):
116 h = x

Callers

nothing calls this directly

Calls 2

NormalizeFunction · 0.85
__init__Method · 0.45

Tested by

no test coverage detected