How to Caculate parameters using pytorch in Convolutional neural networks?

Is there any pytorch module which automatically gives me result of the number of parameters in a Convolutional Neural Network layer (similar keras

1 Like

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 +=

That snippet can be reduced to:

sum( for p in net.parameters())

1 Like