Initialize SkipConvBackbone.
(self, dim_in: int, dim_out: int, kernel_size: int, stride_out: int)
| 94 | """A wrapper around a conv layer that behaves like a BaseBackbone.""" |
| 95 | |
| 96 | def __init__(self, dim_in: int, dim_out: int, kernel_size: int, stride_out: int): |
| 97 | """Initialize SkipConvBackbone.""" |
| 98 | super().__init__() |
| 99 | self.stride_out = stride_out |
| 100 | if stride_out == 1 and kernel_size != 1: |
| 101 | raise ValueError("We only support kernel_size = 1 if stride_out is 1.") |
| 102 | padding: int = (kernel_size - 1) // 2 |
| 103 | self.conv = nn.Conv2d( |
| 104 | dim_in, dim_out, kernel_size=kernel_size, stride=stride_out, padding=padding |
| 105 | ) |
| 106 | |
| 107 | def forward( |
| 108 | self, |