MCPcopy Create free account
hub / github.com/VisionRush/DeepFakeDefenders / __init__

Method __init__

model/replknet.py:78–96  ·  view source on GitHub ↗
(self, in_channels, out_channels, kernel_size,
                 stride, groups,
                 small_kernel,
                 small_kernel_merged=False)

Source from the content-addressed store, hash-verified

76class ReparamLargeKernelConv(nn.Module):
77
78 def __init__(self, in_channels, out_channels, kernel_size,
79 stride, groups,
80 small_kernel,
81 small_kernel_merged=False):
82 super(ReparamLargeKernelConv, self).__init__()
83 self.kernel_size = kernel_size
84 self.small_kernel = small_kernel
85 # We assume the conv does not change the feature map size, so padding = k//2. Otherwise, you may configure padding as you wish, and change the padding of small_conv accordingly.
86 padding = kernel_size // 2
87 if small_kernel_merged:
88 self.lkb_reparam = get_conv2d(in_channels=in_channels, out_channels=out_channels, kernel_size=kernel_size,
89 stride=stride, padding=padding, dilation=1, groups=groups, bias=True)
90 else:
91 self.lkb_origin = conv_bn(in_channels=in_channels, out_channels=out_channels, kernel_size=kernel_size,
92 stride=stride, padding=padding, dilation=1, groups=groups)
93 if small_kernel is not None:
94 assert small_kernel <= kernel_size, 'The kernel size for re-param cannot be larger than the large kernel!'
95 self.small_conv = conv_bn(in_channels=in_channels, out_channels=out_channels, kernel_size=small_kernel,
96 stride=stride, padding=small_kernel//2, groups=groups, dilation=1)
97
98 def forward(self, inputs):
99 if hasattr(self, 'lkb_reparam'):

Callers

nothing calls this directly

Calls 3

get_conv2dFunction · 0.85
conv_bnFunction · 0.85
__init__Method · 0.45

Tested by

no test coverage detected