We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
class DynamicDWConv(nn.Module): def __init__(self, dim, kernel_size, bias=True, stride=1, padding=1, groups=1, reduction=4): super().__init__() self.dim = dim self.kernel_size = kernel_size self.stride = stride self.padding = padding self.groups = groups self.pool = nn.AdaptiveAvgPool2d((1, 1)) self.conv1 = nn.Conv2d(dim, dim // reduction, 1, bias=False) self.bn = nn.BatchNorm2d(dim // reduction) self.relu = nn.ReLU(inplace=True) self.conv2 = nn.Conv2d(dim // reduction, dim * kernel_size * kernel_size, 1) if bias: self.bias = nn.Parameter(torch.zeros(dim)) else: self.bias = None def forward(self, x): b, c, h, w = x.shape weight = self.conv2(self.relu(self.bn(self.conv1(self.pool(x))))) weight = weight.view(b * self.dim, 1, self.kernel_size, self.kernel_size) x = F.conv2d(x.reshape(1, -1, h, w), weight, self.bias.repeat(b), stride=self.stride, padding=self.padding, groups=b * self.groups) x = x.view(b, c, x.shape[-2], x.shape[-1]) return x
This function seems to give error when groups is not equal to dim.
groups
dim
The text was updated successfully, but these errors were encountered:
No branches or pull requests
This function seems to give error when
groups
is not equal todim
.The text was updated successfully, but these errors were encountered: