MCPcopy Create free account
hub / github.com/OpenDriveLab/ReSim / __init__

Method __init__

sat/sgm/modules/diffusionmodules/model.py:86–112  ·  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

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

Callers

nothing calls this directly

Calls 2

NormalizeFunction · 0.70
__init__Method · 0.45

Tested by

no test coverage detected