{"id":18527903,"url":"https://github.com/nemonameless/pytorch_summary","last_synced_at":"2025-05-14T21:33:19.141Z","repository":{"id":118413180,"uuid":"179127667","full_name":"nemonameless/pytorch_summary","owner":"nemonameless","description":"Calculate parameters quantity, memory, and flops in simple and complex way.","archived":false,"fork":false,"pushed_at":"2019-03-20T14:04:45.000Z","size":29,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-17T06:30:26.888Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nemonameless.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-04-02T17:35:20.000Z","updated_at":"2022-12-27T10:18:36.000Z","dependencies_parsed_at":"2023-03-13T12:45:10.062Z","dependency_job_id":null,"html_url":"https://github.com/nemonameless/pytorch_summary","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nemonameless%2Fpytorch_summary","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nemonameless%2Fpytorch_summary/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nemonameless%2Fpytorch_summary/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nemonameless%2Fpytorch_summary/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nemonameless","download_url":"https://codeload.github.com/nemonameless/pytorch_summary/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254231380,"owners_count":22036357,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-06T17:56:16.393Z","updated_at":"2025-05-14T21:33:19.116Z","avatar_url":"https://github.com/nemonameless.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PyTorch_summary\nPyTorch summary:\n\nCalculate parameters quantity, memory,  run-time, and flops in simple and complex way.\n\n# NEW\n\n- Support run-time test.\n- Support both GPU and CPU for **simple mode** and **complex mode**\n- PyTorch 1.0 and 0.4 supported.\n\n## Useage:\nAdd your model to summary.py \n```\n###### add your model ######\nfrom torchvision import models\nmodel = models.resnet50() \n############################\n```\nRun summary.py\n```\npython3 summary.py  --mod simple --gpu -1 --size 3,224,224\n--mod simple|complex|val \n--gpu (gpu id, -1:use cpu)\n--size (input size, split with ,)\n--runtime (if runtime is -1: disable runtime\u003e=1 iters for runtime test.)\n```\n\n## Results:\n\n### simplesum mode:\n\n```\n  + Number of params: 25.56M\n  + Number of FLOPs: 4.11G\n```\n### run-time test:\n```\nTesting runtime using TITAN X (Pascal)\nRun-Time: 141.8995 ms\n```\n\n### complexsum mode:\n\nfollowing  https://github.com/ceykmc/pytorch_model_summary , and add the support to  bilinear layer.\n\n```\n                 module name   input shape  output shape  parameter quantity inference memory(MB)         MAdd duration percent\n0               conv1_Conv2d     3 224 224    64 112 112                9408               3.06MB  235,225,088            6.32%\n1            bn1_BatchNorm2d    64 112 112    64 112 112                 128               3.06MB    3,211,264            0.91%\n2                  relu_ReLU    64 112 112    64 112 112                   0               3.06MB      802,816            0.94%\n3          maxpool_MaxPool2d    64 112 112    64  56  56                   0               0.77MB    1,605,632            3.58%\n4      layer1.0.conv1_Conv2d    64  56  56    64  56  56                4096               0.77MB   25,489,408            0.45%\n5   layer1.0.bn1_BatchNorm2d    64  56  56    64  56  56                 128               0.77MB      802,816            0.21%\n6      layer1.0.conv2_Conv2d    64  56  56    64  56  56               36864               0.77MB  231,010,304            2.75%\n7   layer1.0.bn2_BatchNorm2d    64  56  56    64  56  56                 128               0.77MB      802,816            0.22%\n8      layer1.0.conv3_Conv2d    64  56  56   256  56  56               16384               3.06MB  101,957,632            1.38%\n9   layer1.0.bn3_BatchNorm2d   256  56  56   256  56  56                 512               3.06MB    3,211,264            0.78%\n10        layer1.0.relu_ReLU   256  56  56   256  56  56                   0               3.06MB      802,816            0.53%\n11       layer1.0.downsample    64  56  56   256  56  56               16896               6.12MB  105,168,896            2.13%\n12                  layer1.1   256  56  56   256  56  56               70400              12.25MB  441,147,392            6.28%\n13                  layer1.2   256  56  56   256  56  56               70400              12.25MB  441,147,392            6.24%\n14     layer2.0.conv1_Conv2d   256  56  56   128  56  56               32768               1.53MB  205,119,488            1.94%\n15  layer2.0.bn1_BatchNorm2d   128  56  56   128  56  56                 256               1.53MB    1,605,632            0.20%\n16     layer2.0.conv2_Conv2d   128  56  56   128  28  28              147456               0.38MB  231,110,656            2.65%\n17  layer2.0.bn2_BatchNorm2d   128  28  28   128  28  28                 256               0.38MB      401,408            0.08%\n18     layer2.0.conv3_Conv2d   128  28  28   512  28  28               65536               1.53MB  102,359,040            0.96%\n19  layer2.0.bn3_BatchNorm2d   512  28  28   512  28  28                1024               1.53MB    1,605,632            0.25%\n20        layer2.0.relu_ReLU   512  28  28   512  28  28                   0               1.53MB      401,408            0.26%\n21       layer2.0.downsample   256  56  56   512  28  28              132096               3.06MB  206,725,120            1.93%\n22                  layer2.1   512  28  28   512  28  28              280064               6.12MB  438,939,648            4.36%\n23                  layer2.2   512  28  28   512  28  28              280064               6.12MB  438,939,648            4.47%\n24                  layer2.3   512  28  28   512  28  28              280064               6.12MB  438,939,648            4.44%\n25     layer3.0.conv1_Conv2d   512  28  28   256  28  28              131072               0.77MB  205,320,192            1.48%\n26  layer3.0.bn1_BatchNorm2d   256  28  28   256  28  28                 512               0.77MB      802,816            0.14%\n27     layer3.0.conv2_Conv2d   256  28  28   256  14  14              589824               0.19MB  231,160,832            2.02%\n28  layer3.0.bn2_BatchNorm2d   256  14  14   256  14  14                 512               0.19MB      200,704            0.08%\n29     layer3.0.conv3_Conv2d   256  14  14  1024  14  14              262144               0.77MB  102,559,744            0.77%\n30  layer3.0.bn3_BatchNorm2d  1024  14  14  1024  14  14                2048               0.77MB      802,816            0.28%\n31        layer3.0.relu_ReLU  1024  14  14  1024  14  14                   0               0.77MB      200,704            0.15%\n32       layer3.0.downsample   512  28  28  1024  14  14              526336               1.53MB  206,123,008            1.76%\n33                  layer3.1  1024  14  14  1024  14  14             1117184               3.06MB  437,835,776            3.97%\n34                  layer3.2  1024  14  14  1024  14  14             1117184               3.06MB  437,835,776            4.06%\n35                  layer3.3  1024  14  14  1024  14  14             1117184               3.06MB  437,835,776            4.05%\n36                  layer3.4  1024  14  14  1024  14  14             1117184               3.06MB  437,835,776            4.03%\n37                  layer3.5  1024  14  14  1024  14  14             1117184               3.06MB  437,835,776            4.02%\n38     layer4.0.conv1_Conv2d  1024  14  14   512  14  14              524288               0.38MB  205,420,544            1.42%\n39  layer4.0.bn1_BatchNorm2d   512  14  14   512  14  14                1024               0.38MB      401,408            0.14%\n40     layer4.0.conv2_Conv2d   512  14  14   512   7   7             2359296               0.10MB  231,185,920            2.41%\n41  layer4.0.bn2_BatchNorm2d   512   7   7   512   7   7                1024               0.10MB      100,352            0.13%\n42     layer4.0.conv3_Conv2d   512   7   7  2048   7   7             1048576               0.38MB  102,660,096            1.03%\n43  layer4.0.bn3_BatchNorm2d  2048   7   7  2048   7   7                4096               0.38MB      401,408            0.44%\n44        layer4.0.relu_ReLU  2048   7   7  2048   7   7                   0               0.38MB      100,352            0.08%\n45       layer4.0.downsample  1024  14  14  2048   7   7             2101248               0.77MB  205,821,952            2.48%\n46                  layer4.1  2048   7   7  2048   7   7             4462592               1.53MB  437,283,840            5.26%\n47                  layer4.2  2048   7   7  2048   7   7             4462592               1.53MB  437,283,840            5.27%\n48         avgpool_AvgPool2d  2048   7   7  2048   1   1                   0               0.01MB      100,352            0.05%\n49                 fc_Linear          2048          1000             2049000               0.00MB    4,095,000            0.24%\n===============================================================================================================================\ntotal parameters quantity: 25,557,032\ntotal memory: 109.69MB\ntotal MAdd: 8,219,737,624\n\n```\n### validation mode\n To make sure the result is correct, a validation mothod from https://github.com/sksq96/pytorch-summary is added.\n To use this validation method, please install  *torchsummary*\n `pip3 install torchsummary`","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnemonameless%2Fpytorch_summary","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnemonameless%2Fpytorch_summary","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnemonameless%2Fpytorch_summary/lists"}