Hi friend,
Sorry to bother you under this question. I have met similar error as below:
Traceback (most recent call last):
  File "D:/Code/Pconv/calculate param.py", line 64, in <module>
    flops7, params7 = profile(model7, inputs=(input,),verbose=False)
  File "C:\Users\zhy34\anaconda3\lib\site-packages\thop\profile.py", line 188, in profile
    model(*inputs)
  File "C:\Users\zhy34\anaconda3\lib\site-packages\torch\nn\modules\module.py", line 722, in _call_impl
    result = self.forward(*input, **kwargs)
  File "D:\Code\Pconv\models\resnet_AC.py", line 161, in forward
    out = self.linear(out)
  File "C:\Users\zhy34\anaconda3\lib\site-packages\torch\nn\modules\module.py", line 722, in _call_impl
    result = self.forward(*input, **kwargs)
  File "C:\Users\zhy34\anaconda3\lib\site-packages\torch\nn\modules\linear.py", line 91, in forward
    return F.linear(input, self.weight, self.bias)
  File "C:\Users\zhy34\anaconda3\lib\site-packages\torch\nn\functional.py", line 1674, in linear
    ret = torch.addmm(bias, input, weight.t())
RuntimeError: size mismatch, m1: [1 x 25088], m2: [512 x 7] at ..\aten\src\TH/generic/THTensorMath.cpp:41

Process finished with exit code 1

The error comes from the condition when I calculate the FLOPs of my model. I used this code:
model7 = ResNet18_AC()
input = torch.randn(1, 3, 224, 224)
flops7, params7 = profile(model7, inputs=(input,),verbose=False)
print(params7)
print(flops7)

And my model is here:
from ACNet_master.acnet.acb import ACBlock

def conv(in_channels, out_channels, kernel_size=3, stride=1, padding=1, dilation=1, groups=1):
    """replace 3*3 to AC block"""
    return ACBlock(in_channels, out_channels, kernel_size=kernel_size, stride=stride, padding=padding, dilation=dilation, groups=groups)

def conv3x3(in_planes, out_planes, kernel_size=3, stride=1, padding=1, dilation=1, groups=1):
    """standard convolution with padding"""
    return nn.Conv2d(in_planes, out_planes, kernel_size=kernel_size, stride=stride, padding=padding, dilation=dilation, groups=groups, bias=False)

class BasicBlock(nn.Module):
    expansion = 1

    def __init__(self, in_planes, planes, stride=1):
        super(BasicBlock, self).__init__()
        self.conv1 = conv(in_planes, planes, kernel_size=3, stride=stride, padding=1)
        self.conv2 = conv(planes, planes, kernel_size=3, stride=1, padding=1)

        self.shortcut = nn.Sequential()
        if stride != 1 or in_planes != self.expansion*planes:
            self.shortcut = nn.Sequential(
                nn.Conv2d(in_planes, self.expansion*planes, kernel_size=1, stride=stride, bias=False),
                nn.BatchNorm2d(self.expansion*planes)
            )

    def forward(self, x):
        out = self.conv1(x)
        #out = self.bn1(out)
        out = F.relu(out)

        out = self.conv2(out)

        out += self.shortcut(x)
        out = F.relu(out)

        return out


class Bottleneck(nn.Module):
    expansion = 4

    def __init__(self, in_planes, planes, stride=1):
        super(Bottleneck, self).__init__()
        self.conv1 = nn.Conv2d(in_planes, planes, kernel_size=1, bias=False)
        self.bn1 = nn.BatchNorm2d(planes)

        self.conv2 = conv(planes, planes, kernel_size=3, stride=stride, padding=1)
        self.bn2 = nn.BatchNorm2d(planes)

        self.conv3 = nn.Conv2d(planes, self.expansion*planes, kernel_size=1, bias=False)
        self.bn3 = nn.BatchNorm2d(self.expansion*planes)

        self.shortcut = nn.Sequential()
        if stride != 1 or in_planes != self.expansion*planes:
            self.shortcut = nn.Sequential(
                nn.Conv2d(in_planes, self.expansion*planes, kernel_size=1, stride=stride, bias=False),
                nn.BatchNorm2d(self.expansion*planes)
            )

    def forward(self, x):
        out = self.conv1(x)
        out = self.bn1(out)
        out = F.relu(out)

        out = self.conv2(out)
        out = F.relu(out)

        out = self.conv3(out)
        out = self.bn3(out)

        out += self.shortcut(x)
        out = F.relu(out)

        return out


class resnet(nn.Module):
    def __init__(self, block, num_blocks, num_classes=7, zero_init_residual=False):
        super(resnet, self).__init__()
        self.in_planes = 64

        self.conv1 = conv(3, 64, kernel_size=3, stride=1, padding=1)

        self.layer1 = self._make_layer(block, 64, num_blocks[0], stride=1)
        self.layer2 = self._make_layer(block, 128, num_blocks[1], stride=2)
        self.layer3 = self._make_layer(block, 256, num_blocks[2], stride=2)
        self.layer4 = self._make_layer(block, 512, num_blocks[3], stride=2)
        self.linear = nn.Linear(512, num_classes)

    def _make_layer(self, block, planes, num_blocks, stride):
        strides = [stride] + [1]*(num_blocks-1)
        layers = []
        for stride in strides:
            layers.append(block(self.in_planes, planes, stride))
            self.in_planes = planes * block.expansion
        return nn.Sequential(*layers)

    def forward(self, x):
        out = self.conv1(x)
        #out = self.bn1(out)
        out = F.relu(out)

        out = self.layer1(out)
        out = self.layer2(out)
        out = self.layer3(out)
        out = self.layer4(out)

        out = F.avg_pool2d(out, 4)
        out = out.view(out.size(0), -1)
        out = F.dropout(out, p=0.5, training=self.training)
        out = self.linear(out)

        return out


def ResNet18_AC():
    return resnet(BasicBlock, [2,2,2,2])

def ResNet34_AC():
    return resnet(BasicBlock, [3,4,6,3])

def ResNet50_AC():
    return resnet(Bottleneck, [3,4,6,3])

I just use ResNet, but change 33 block to an asymmetric convolution (a sequence of 33, 31, and 13). I don’t wanna post too much code here, the library I import to the model “from ACNet_master.acnet.acb import ACBlock” is from this paper “https://openaccess.thecvf.com/content_ICCV_2019/papers/Ding_ACNet_Strengthening_the_Kernel_Skeletons_for_Powerful_CNN_via_Asymmetric_ICCV_2019_paper.pdf”. And the code is this: “ACNet/acb.py at master · DingXiaoH/ACNet · GitHub”
I will be very appreciated if you can give me some suggestions!