MCPcopy Create free account
hub / github.com/MaverickPeter/vDiSCO / SparseBasicBlock

Class SparseBasicBlock

prnet/models/backbones_3d/spconv_backbone.py:30–66  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28
29
30class SparseBasicBlock(spconv.SparseModule):
31 expansion = 1
32
33 def __init__(self, inplanes, planes, stride=1, norm_fn=None, downsample=None, indice_key=None):
34 super(SparseBasicBlock, self).__init__()
35
36 assert norm_fn is not None
37 bias = norm_fn is not None
38 self.conv1 = spconv.SubMConv3d(
39 inplanes, planes, kernel_size=3, stride=stride, padding=1, bias=bias, indice_key=indice_key
40 )
41 self.bn1 = norm_fn(planes)
42 self.relu = nn.ReLU()
43 self.conv2 = spconv.SubMConv3d(
44 planes, planes, kernel_size=3, stride=stride, padding=1, bias=bias, indice_key=indice_key
45 )
46 self.bn2 = norm_fn(planes)
47 self.downsample = downsample
48 self.stride = stride
49
50 def forward(self, x):
51 identity = x
52
53 out = self.conv1(x)
54 out = replace_feature(out, self.bn1(out.features))
55 out = replace_feature(out, self.relu(out.features))
56
57 out = self.conv2(out)
58 out = replace_feature(out, self.bn2(out.features))
59
60 if self.downsample is not None:
61 identity = self.downsample(x)
62
63 out = replace_feature(out, out.features + identity.features)
64 out = replace_feature(out, self.relu(out.features))
65
66 return out
67
68
69class VoxelBackBone8x(nn.Module):

Callers 1

__init__Method · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected