Is there any pytorch module which automatically gives me result of the number of parameters in a Convolutional Neural Network layer (similar keras topology.py)?
I think it is easy to calculate the number of elements in PyTorch. Suppose you have a model called
net. You can use the following snippet to calculate the number of parameter in your model:
count = 0 for p in net.parameters(): count += p.data.nelement()
That snippet can be reduced to:
sum(p.data.nelement() for p in net.parameters())