The expected FLOPs count is 2,240, while thop shows 2160, which apparently overlooks biases term.
`import thop
x = torch.randn(size=(1, 3, 6, 6))
class Model(nn.Module):
def init(self):
super().init()
self.conv = nn.Sequential(
nn.Conv2d(in_channels=3, out_channels=5, kernel_size=(3, 3), groups=1, bias=True),
)
def forward(self, x):
x = self.conv(x)
return x
model = Model()
output = model(x)
print(f'output shape: {output.size()}')
FLOPs, params = thop.profile(model=model, inputs=(x,), verbose=False)
print(f'FLOPs: {FLOPs}')
print(f'Parameters: {params}')`
The expected FLOPs count is 2,240, while
thopshows 2160, which apparently overlooks biases term.`import thop
x = torch.randn(size=(1, 3, 6, 6))
class Model(nn.Module):
def init(self):
super().init()
self.conv = nn.Sequential(
nn.Conv2d(in_channels=3, out_channels=5, kernel_size=(3, 3), groups=1, bias=True),
)
model = Model()
output = model(x)
print(f'output shape: {output.size()}')
FLOPs, params = thop.profile(model=model, inputs=(x,), verbose=False)
print(f'FLOPs: {FLOPs}')
print(f'Parameters: {params}')`