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

Method __init__

sat/sgm/modules/autoencoding/vqvae/vqvae_blocks.py:71–89  ·  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

69
70class ResnetBlock(nn.Module):
71 def __init__(self, *, in_channels, out_channels=None, conv_shortcut=False, dropout, temb_channels=512):
72 super().__init__()
73 self.in_channels = in_channels
74 out_channels = in_channels if out_channels is None else out_channels
75 self.out_channels = out_channels
76 self.use_conv_shortcut = conv_shortcut
77
78 self.norm1 = Normalize(in_channels)
79 self.conv1 = torch.nn.Conv2d(in_channels, out_channels, kernel_size=3, stride=1, padding=1)
80 if temb_channels > 0:
81 self.temb_proj = torch.nn.Linear(temb_channels, out_channels)
82 self.norm2 = Normalize(out_channels)
83 self.dropout = torch.nn.Dropout(dropout)
84 self.conv2 = torch.nn.Conv2d(out_channels, out_channels, kernel_size=3, stride=1, padding=1)
85 if self.in_channels != self.out_channels:
86 if self.use_conv_shortcut:
87 self.conv_shortcut = torch.nn.Conv2d(in_channels, out_channels, kernel_size=3, stride=1, padding=1)
88 else:
89 self.nin_shortcut = torch.nn.Conv2d(in_channels, out_channels, kernel_size=1, stride=1, padding=0)
90
91 def forward(self, x, temb):
92 h = x

Callers

nothing calls this directly

Calls 2

NormalizeFunction · 0.70
__init__Method · 0.45

Tested by

no test coverage detected