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

Method __init__

ML/src/python/neuralforge/nn/layers.py:7–24  ·  view source on GitHub ↗
(self, in_channels, out_channels, kernel_size=3, stride=1, padding=1, 
                 use_bn=True, activation='relu', drop_rate=0.0)

Source from the content-addressed store, hash-verified

5
6class ConvBlock(nn.Module):
7 def __init__(self, in_channels, out_channels, kernel_size=3, stride=1, padding=1,
8 use_bn=True, activation='relu', drop_rate=0.0):
9 super().__init__()
10 self.conv = nn.Conv2d(in_channels, out_channels, kernel_size, stride, padding, bias=not use_bn)
11 self.bn = nn.BatchNorm2d(out_channels) if use_bn else nn.Identity()
12
13 if activation == 'relu':
14 self.activation = nn.ReLU(inplace=True)
15 elif activation == 'gelu':
16 self.activation = nn.GELU()
17 elif activation == 'silu':
18 self.activation = nn.SiLU(inplace=True)
19 elif activation == 'mish':
20 self.activation = nn.Mish(inplace=True)
21 else:
22 self.activation = nn.Identity()
23
24 self.dropout = nn.Dropout2d(drop_rate) if drop_rate > 0 else nn.Identity()
25
26 def forward(self, x):
27 x = self.conv(x)

Callers

nothing calls this directly

Calls 1

__init__Method · 0.45

Tested by

no test coverage detected