How to determine how many learnable parameters

Is there a simple function that I can call to return how many learnable parameters there are in my model? I want to compare two different architectures and would like to know exactly how many parameters each model has.

Thanks for your help

The newly implemented model_summary function (in callbacks.hooks) gives you that. It doesn’t work on all models yet though.

1 Like

Thanks, I will give it a try

def calc_net_weight_count(net):
net_params = filter(lambda p: p.requires_grad, net.parameters())
weight_count = 0
for param in net_params:
weight_count +=
return weight_count

for a learner just call the function on net.model (or whatever your Learner is called).

This works perfect!