Skip to content

Instantly share code, notes, and snippets.

@naviocean
Created November 17, 2020 07:46
Show Gist options
  • Save naviocean/37d5cb35b4dff4541c6598ac152ffaf7 to your computer and use it in GitHub Desktop.
Save naviocean/37d5cb35b4dff4541c6598ac152ffaf7 to your computer and use it in GitHub Desktop.

Revisions

  1. naviocean renamed this gist Nov 17, 2020. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions gistfile1.txt → get_n_params.py
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    ```

    # reference
    # https://discuss.pytorch.org/t/how-do-i-check-the-number-of-parameters-of-a-model/4325
    def get_n_params(model):
    @@ -12,4 +12,3 @@ def get_n_params(model):

    model = LambdaResNet50()
    print(get_n_params(model)) # 14.9M (Ours) / 15M(Paper)
    ```
  2. naviocean created this gist Nov 17, 2020.
    15 changes: 15 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    ```
    # reference
    # https://discuss.pytorch.org/t/how-do-i-check-the-number-of-parameters-of-a-model/4325
    def get_n_params(model):
    pp=0
    for p in list(model.parameters()):
    nn=1
    for s in list(p.size()):
    nn = nn*s
    pp += nn
    return pp

    model = LambdaResNet50()
    print(get_n_params(model)) # 14.9M (Ours) / 15M(Paper)
    ```