Bread / tools /model_utils.py
huqiming513's picture
Upload 13 files
2a2ae9a
raw
history blame contribute delete
301 Bytes
def count_parameters(model):
return sum(p.numel() for p in model.parameters() if p.requires_grad)
def count_conv_layers(model):
cnt = 0
for mo in model().modules():
if type(mo).__name__ == 'Conv2d':
cnt += 1
print(model.__name__, cnt, count_parameters(model()))