MCPcopy
hub / github.com/princeton-vl/RAFT / __init__

Method __init__

core/extractor.py:196–233  ·  view source on GitHub ↗
(self, output_dim=128, norm_fn='batch', dropout=0.0)

Source from the content-addressed store, hash-verified

194
195class SmallEncoder(nn.Module):
196 def __init__(self, output_dim=128, norm_fn='batch', dropout=0.0):
197 super(SmallEncoder, self).__init__()
198 self.norm_fn = norm_fn
199
200 if self.norm_fn == 'group':
201 self.norm1 = nn.GroupNorm(num_groups=8, num_channels=32)
202
203 elif self.norm_fn == 'batch':
204 self.norm1 = nn.BatchNorm2d(32)
205
206 elif self.norm_fn == 'instance':
207 self.norm1 = nn.InstanceNorm2d(32)
208
209 elif self.norm_fn == 'none':
210 self.norm1 = nn.Sequential()
211
212 self.conv1 = nn.Conv2d(3, 32, kernel_size=7, stride=2, padding=3)
213 self.relu1 = nn.ReLU(inplace=True)
214
215 self.in_planes = 32
216 self.layer1 = self._make_layer(32, stride=1)
217 self.layer2 = self._make_layer(64, stride=2)
218 self.layer3 = self._make_layer(96, stride=2)
219
220 self.dropout = None
221 if dropout > 0:
222 self.dropout = nn.Dropout2d(p=dropout)
223
224 self.conv2 = nn.Conv2d(96, output_dim, kernel_size=1)
225
226 for m in self.modules():
227 if isinstance(m, nn.Conv2d):
228 nn.init.kaiming_normal_(m.weight, mode='fan_out', nonlinearity='relu')
229 elif isinstance(m, (nn.BatchNorm2d, nn.InstanceNorm2d, nn.GroupNorm)):
230 if m.weight is not None:
231 nn.init.constant_(m.weight, 1)
232 if m.bias is not None:
233 nn.init.constant_(m.bias, 0)
234
235 def _make_layer(self, dim, stride=1):
236 layer1 = BottleneckBlock(self.in_planes, dim, self.norm_fn, stride=stride)

Callers

nothing calls this directly

Calls 2

_make_layerMethod · 0.95
__init__Method · 0.45

Tested by

no test coverage detected