Res block, preserve spatial resolution.
| 77 | |
| 78 | |
| 79 | class ResBlock3d(nn.Module): |
| 80 | """ |
| 81 | Res block, preserve spatial resolution. |
| 82 | """ |
| 83 | |
| 84 | def __init__(self, in_features, kernel_size, padding): |
| 85 | super(ResBlock3d, self).__init__() |
| 86 | self.conv1 = nn.Conv3d(in_channels=in_features, out_channels=in_features, kernel_size=kernel_size, padding=padding) |
| 87 | self.conv2 = nn.Conv3d(in_channels=in_features, out_channels=in_features, kernel_size=kernel_size, padding=padding) |
| 88 | self.norm1 = nn.BatchNorm3d(in_features, affine=True) |
| 89 | self.norm2 = nn.BatchNorm3d(in_features, affine=True) |
| 90 | |
| 91 | def forward(self, x): |
| 92 | out = self.norm1(x) |
| 93 | out = F.relu(out) |
| 94 | out = self.conv1(out) |
| 95 | out = self.norm2(out) |
| 96 | out = F.relu(out) |
| 97 | out = self.conv2(out) |
| 98 | out += x |
| 99 | return out |
| 100 | |
| 101 | |
| 102 | class UpBlock3d(nn.Module): |