Last active
June 26, 2022 15:13
-
-
Save bdsaglam/b16de6ae6662e7a783e06e58e2c5185a to your computer and use it in GitHub Desktop.
Depthwise 2D Convolution PyTorch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import torch | |
| class DepthwiseConv2d(torch.nn.Conv2d): | |
| def __init__(self, | |
| in_channels, | |
| depth_multiplier=1, | |
| kernel_size=3, | |
| stride=1, | |
| padding=0, | |
| dilation=1, | |
| bias=True, | |
| padding_mode='zeros' | |
| ): | |
| out_channels = in_channels * depth_multiplier | |
| super().__init__( | |
| in_channels=in_channels, | |
| out_channels=out_channels, | |
| kernel_size=kernel_size, | |
| stride=stride, | |
| padding=padding, | |
| dilation=dilation, | |
| groups=in_channels, | |
| bias=bias, | |
| padding_mode=padding_mode | |
| ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment