| 41 | |
| 42 | |
| 43 | class ResidualBlock(nn.Module): |
| 44 | def __init__(self, inc, outc, ks=3, stride=1, dilation=1): |
| 45 | super().__init__() |
| 46 | self.net = nn.Sequential( |
| 47 | spnn.Conv3d(inc, |
| 48 | outc, |
| 49 | kernel_size=ks, |
| 50 | dilation=dilation, |
| 51 | stride=stride), spnn.BatchNorm(outc), |
| 52 | spnn.ReLU(True), |
| 53 | spnn.Conv3d(outc, |
| 54 | outc, |
| 55 | kernel_size=ks, |
| 56 | dilation=dilation, |
| 57 | stride=1), |
| 58 | spnn.BatchNorm(outc) |
| 59 | ) |
| 60 | |
| 61 | self.downsample = nn.Sequential() if (inc == outc and stride == 1) else \ |
| 62 | nn.Sequential( |
| 63 | spnn.Conv3d(inc, outc, kernel_size=1, dilation=1, stride=stride), |
| 64 | spnn.BatchNorm(outc) |
| 65 | ) |
| 66 | |
| 67 | self.relu = spnn.ReLU(True) |
| 68 | |
| 69 | def forward(self, x): |
| 70 | out = self.relu(self.net(x) + self.downsample(x)) |
| 71 | return out |
| 72 | |
| 73 | |
| 74 | class SPVCNN_CLASSIFICATION(nn.Module): |