basic block (no BN)
| 40 | |
| 41 | |
| 42 | class ResBlock2d(nn.Module): |
| 43 | """ |
| 44 | basic block (no BN) |
| 45 | """ |
| 46 | |
| 47 | def __init__(self, in_features, out_features, kernel_size, padding): |
| 48 | super(ResBlock2d, self).__init__() |
| 49 | self.in_features = in_features |
| 50 | self.out_features = out_features |
| 51 | self.conv1 = nn.Conv2d( |
| 52 | in_channels=in_features, |
| 53 | out_channels=in_features, |
| 54 | kernel_size=kernel_size, |
| 55 | padding=padding, |
| 56 | ) |
| 57 | self.conv2 = nn.Conv2d( |
| 58 | in_channels=in_features, |
| 59 | out_channels=out_features, |
| 60 | kernel_size=kernel_size, |
| 61 | padding=padding, |
| 62 | ) |
| 63 | if out_features != in_features: |
| 64 | self.channel_conv = nn.Conv2d(in_features, out_features, 1) |
| 65 | self.relu = nn.ReLU() |
| 66 | |
| 67 | def forward(self, x): |
| 68 | out = self.relu(x) |
| 69 | out = self.conv1(out) |
| 70 | out = self.relu(out) |
| 71 | out = self.conv2(out) |
| 72 | if self.in_features != self.out_features: |
| 73 | out += self.channel_conv(x) |
| 74 | else: |
| 75 | out += x |
| 76 | return out |
| 77 | |
| 78 | |
| 79 | class DownBlock1d(nn.Module): |