MarcoForte / FBA_Matting

Official repository for the paper F, B, Alpha Matting
MIT License
464 stars 95 forks source link

Parameter Size #47

Closed Serge-weihao closed 3 years ago

Serge-weihao commented 3 years ago

Is it correct to count your model size as 33.08585262298584M (1024X1024) parameters?

99991 commented 3 years ago

That are 33,085,852.62298584 parameters. Where do you get the fractional 0.62298584 parameter from?

Anyway, you can count the parameters like so:

count = 0
for W in model.parameters():
    count += np.product(W.shape)
print(f"{count * 1e-6} million parameters")

This gives me 34.693031 million parameters. But the number could be wrong if there are any unused layers.

Nevertheless, it is pretty close to the 34.7 million parameters you get when dividing the filesize 138813960 of FBA.pth by 4, i.e. the size of a float, so it is probably in the right ballpark. The FBA.pth file of course includes a few more bytes like layer names and such, so it is not too surprising that the estimate is slightly higher.

Serge-weihao commented 3 years ago

I count 34693031 parameters and I use 1M =1024X1024. I am not sure about what M refers to in general in CV papers.

99991 commented 3 years ago

"M" stands for million, i.e. 1,000,000. For reference see the corresponding row in this table: https://en.wikipedia.org/wiki/Metric_prefix#List_of_SI_prefixes

Some authors might state their model size in megabyte, either with "MB" (10^6) or "MiB" (2^20 i.e. 1024^2) suffix.

See https://en.wikipedia.org/wiki/Byte#Multiple-byte_units for reference.

Serge-weihao commented 3 years ago

Ok, thanks