MCPcopy Create free account
hub / github.com/MotrixLab/AiOS / SmoothNetResBlock

Class SmoothNetResBlock

detrsmpl/core/post_processing/smooth/smoothnet.py:17–45  ·  view source on GitHub ↗

Residual block module used in SmoothNet. Args: in_channels (int): Input channel number. hidden_channels (int): The hidden feature channel number. dropout (float): Dropout probability. Default: 0.5 Shape: Input: (*, in_channels) Output: (*, in_channels

Source from the content-addressed store, hash-verified

15
16
17class SmoothNetResBlock(nn.Module):
18 """Residual block module used in SmoothNet.
19
20 Args:
21 in_channels (int): Input channel number.
22 hidden_channels (int): The hidden feature channel number.
23 dropout (float): Dropout probability. Default: 0.5
24 Shape:
25 Input: (*, in_channels)
26 Output: (*, in_channels)
27 """
28 def __init__(self, in_channels, hidden_channels, dropout=0.1):
29 super().__init__()
30 self.linear1 = nn.Linear(in_channels, hidden_channels)
31 self.linear2 = nn.Linear(hidden_channels, in_channels)
32 self.lrelu = nn.LeakyReLU(0.2, inplace=True)
33 self.dropout = nn.Dropout(p=dropout, inplace=True)
34
35 def forward(self, x):
36 identity = x
37 x = self.linear1(x)
38 x = self.dropout(x)
39 x = self.lrelu(x)
40 x = self.linear2(x)
41 x = self.dropout(x)
42 x = self.lrelu(x)
43
44 out = x + identity
45 return out
46
47
48class SmoothNet(nn.Module):

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected