3x3 convolution with padding
(in_channels, out_channels, module_name, postfix, stride=1, kernel_size=3, padding=1)
| 90 | |
| 91 | |
| 92 | def dw_conv3x3(in_channels, out_channels, module_name, postfix, stride=1, kernel_size=3, padding=1): |
| 93 | """3x3 convolution with padding""" |
| 94 | return [ |
| 95 | ( |
| 96 | '{}_{}/dw_conv3x3'.format(module_name, postfix), |
| 97 | nn.Conv2d( |
| 98 | in_channels, |
| 99 | out_channels, |
| 100 | kernel_size=kernel_size, |
| 101 | stride=stride, |
| 102 | padding=padding, |
| 103 | groups=out_channels, |
| 104 | bias=False |
| 105 | ) |
| 106 | ), |
| 107 | ( |
| 108 | '{}_{}/pw_conv1x1'.format(module_name, postfix), |
| 109 | nn.Conv2d(in_channels, out_channels, kernel_size=1, stride=1, padding=0, groups=1, bias=False) |
| 110 | ), |
| 111 | ('{}_{}/pw_norm'.format(module_name, postfix), nn.BatchNorm2d(out_channels)), |
| 112 | ('{}_{}/pw_relu'.format(module_name, postfix), nn.ReLU(inplace=True)), |
| 113 | ] |
| 114 | |
| 115 | |
| 116 | def conv3x3(in_channels, out_channels, module_name, postfix, stride=1, groups=1, kernel_size=3, padding=1): |