MCPcopy Create free account
hub / github.com/geekcomputers/Python / _make_layer

Method _make_layer

ML/src/python/neuralforge/nn/convolution.py:52–67  ·  view source on GitHub ↗
(self, block, out_channels, blocks, stride=1)

Source from the content-addressed store, hash-verified

50 self.fc = nn.Linear(512, num_classes)
51
52 def _make_layer(self, block, out_channels, blocks, stride=1):
53 downsample = None
54 if stride != 1 or self.in_channels != out_channels:
55 downsample = nn.Sequential(
56 nn.Conv2d(self.in_channels, out_channels, kernel_size=1, stride=stride, bias=False),
57 nn.BatchNorm2d(out_channels)
58 )
59
60 layers = []
61 layers.append(block(self.in_channels, out_channels, stride, downsample))
62 self.in_channels = out_channels
63
64 for _ in range(1, blocks):
65 layers.append(block(out_channels, out_channels))
66
67 return nn.Sequential(*layers)
68
69 def forward(self, x):
70 x = self.conv1(x)

Callers 1

__init__Method · 0.95

Calls 1

appendMethod · 0.45

Tested by

no test coverage detected