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

Method __init__

ML/src/python/neuralforge/nn/layers.py:76–91  ·  view source on GitHub ↗
(self, in_channels, out_channels, stride=1, expand_ratio=6)

Source from the content-addressed store, hash-verified

74
75class InvertedResidualBlock(nn.Module):
76 def __init__(self, in_channels, out_channels, stride=1, expand_ratio=6):
77 super().__init__()
78 hidden_dim = in_channels * expand_ratio
79 self.use_residual = stride == 1 and in_channels == out_channels
80
81 layers = []
82 if expand_ratio != 1:
83 layers.append(ConvBlock(in_channels, hidden_dim, kernel_size=1, padding=0))
84
85 layers.extend([
86 ConvBlock(hidden_dim, hidden_dim, kernel_size=3, stride=stride, padding=1, activation='relu'),
87 nn.Conv2d(hidden_dim, out_channels, kernel_size=1, bias=False),
88 nn.BatchNorm2d(out_channels)
89 ])
90
91 self.conv = nn.Sequential(*layers)
92
93 def forward(self, x):
94 if self.use_residual:

Callers

nothing calls this directly

Calls 4

ConvBlockClass · 0.85
extendMethod · 0.80
__init__Method · 0.45
appendMethod · 0.45

Tested by

no test coverage detected