MCPcopy Index your code
hub / github.com/geekcomputers/Python / __init__

Method __init__

ML/src/python/neuralforge/nn/layers.py:49–64  ·  view source on GitHub ↗
(self, in_channels, out_channels, stride=1, expansion=4)

Source from the content-addressed store, hash-verified

47
48class BottleneckBlock(nn.Module):
49 def __init__(self, in_channels, out_channels, stride=1, expansion=4):
50 super().__init__()
51 mid_channels = out_channels // expansion
52
53 self.conv1 = ConvBlock(in_channels, mid_channels, kernel_size=1, padding=0)
54 self.conv2 = ConvBlock(mid_channels, mid_channels, kernel_size=3, stride=stride, padding=1)
55 self.conv3 = ConvBlock(mid_channels, out_channels, kernel_size=1, padding=0, activation='none')
56
57 self.shortcut = nn.Sequential()
58 if stride != 1 or in_channels != out_channels:
59 self.shortcut = nn.Sequential(
60 nn.Conv2d(in_channels, out_channels, kernel_size=1, stride=stride, bias=False),
61 nn.BatchNorm2d(out_channels)
62 )
63
64 self.activation = nn.ReLU(inplace=True)
65
66 def forward(self, x):
67 residual = self.shortcut(x)

Callers

nothing calls this directly

Calls 2

ConvBlockClass · 0.85
__init__Method · 0.45

Tested by

no test coverage detected