# Codeblock 9 class UpSample(nn.Module): def __init__(self, in_channels, out_channels): super().__init__() self.conv_transpose = nn.ConvTranspose2d(in_channels=in_channels, #(1) out_channels=out_channels, kernel_size=2, stride=2) #(2) self.double_conv = DoubleConv(in_channels=in_channels, #(3) out_channels=out_channels) def forward(self, x, t, connection): #(4) print(f'original\t\t: {x.size()}') print(f'timesteps\t\t: {t.size()}, {t}') print(f'connection\t\t: {connection.size()}') x = self.conv_transpose(x) #(5) print(f'\nafter conv transpose\t: {x.size()}') x = torch.cat([x, connection], dim=1) #(6) print(f'after concat\t\t: {x.size()}') x = self.double_conv(x, t) #(7) print(f'after double conv\t: {x.size()}') return x