Residual layer with `in_channels` inputs.
| 102 | |
| 103 | |
| 104 | class ResLayer(nn.Module): |
| 105 | "Residual layer with `in_channels` inputs." |
| 106 | |
| 107 | def __init__(self, in_channels: int): |
| 108 | super().__init__() |
| 109 | mid_channels = in_channels // 2 |
| 110 | self.layer1 = BaseConv( |
| 111 | in_channels, mid_channels, ksize=1, stride=1, act="lrelu" |
| 112 | ) |
| 113 | self.layer2 = BaseConv( |
| 114 | mid_channels, in_channels, ksize=3, stride=1, act="lrelu" |
| 115 | ) |
| 116 | |
| 117 | def forward(self, x): |
| 118 | out = self.layer2(self.layer1(x)) |
| 119 | return x + out |
| 120 | |
| 121 | |
| 122 | class SPPBottleneck(nn.Module): |