| 111 | class ResModule(nn.Module): |
| 112 | |
| 113 | def __init__(self, in_channels, out_channels, stride=1): |
| 114 | super(ResModule, self).__init__() |
| 115 | self.stride = stride |
| 116 | self.conv1 = nn.Conv3d(in_channels, |
| 117 | out_channels, |
| 118 | 3, |
| 119 | stride, |
| 120 | 1, |
| 121 | bias=False) |
| 122 | self.norm1 = nn.BatchNorm3d(out_channels) |
| 123 | self.relu = nn.ReLU(inplace=True) |
| 124 | self.conv2 = nn.Conv3d(out_channels, out_channels, 3, 1, 1, bias=False) |
| 125 | self.norm2 = nn.BatchNorm3d(out_channels) |
| 126 | if self.stride != 1: |
| 127 | self.downsample = nn.Sequential( |
| 128 | nn.Conv3d(in_channels, out_channels, 1, stride, bias=False), |
| 129 | nn.BatchNorm3d(out_channels)) |
| 130 | self.stride = stride |
| 131 | |
| 132 | def forward(self, x): |
| 133 | identity = x |