{"id":13564859,"url":"https://github.com/Swall0w/torchstat","last_synced_at":"2025-04-03T21:32:03.313Z","repository":{"id":38348442,"uuid":"154848329","full_name":"Swall0w/torchstat","owner":"Swall0w","description":"Model analyzer in PyTorch","archived":false,"fork":false,"pushed_at":"2023-03-19T03:13:59.000Z","size":48,"stargazers_count":1465,"open_issues_count":43,"forks_count":142,"subscribers_count":12,"default_branch":"master","last_synced_at":"2024-10-29T17:11:47.241Z","etag":null,"topics":["python","pytorch"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"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/Swall0w.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":"2018-10-26T14:36:14.000Z","updated_at":"2024-10-28T11:10:35.000Z","dependencies_parsed_at":"2024-06-18T15:25:56.704Z","dependency_job_id":null,"html_url":"https://github.com/Swall0w/torchstat","commit_stats":{"total_commits":31,"total_committers":2,"mean_commits":15.5,"dds":"0.12903225806451613","last_synced_commit":"b52a3b06c2c54c2d09ade1a18cf6c4ca5dc27510"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Swall0w%2Ftorchstat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Swall0w%2Ftorchstat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Swall0w%2Ftorchstat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Swall0w%2Ftorchstat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Swall0w","download_url":"https://codeload.github.com/Swall0w/torchstat/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223049546,"owners_count":17079543,"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":["python","pytorch"],"created_at":"2024-08-01T13:01:37.113Z","updated_at":"2024-11-04T18:30:54.086Z","avatar_url":"https://github.com/Swall0w.png","language":"Python","readme":"[![Build Status](https://travis-ci.org/Swall0w/torchstat.svg?branch=master)](https://travis-ci.org/Swall0w/torchstat)\n\n# torchstat\nThis is a lightweight neural network analyzer based on PyTorch.\nIt is designed to make building your networks quick and easy, with the ability to debug them.\n**Note**: This repository is currently under development. Therefore, some APIs might be changed.\n\nThis tools can show\n\n* Total number of network parameters\n* Theoretical amount of floating point arithmetics (FLOPs)\n* Theoretical amount of multiply-adds (MAdd)\n* Memory usage\n\n## Installing\nThere're two ways to install torchstat into your environment.\n* Install it via pip.\n```bash\n$ pip install torchstat\n```\n\n* Install and update using **setup.py** after cloning this repository.\n```bash\n$ python3 setup.py install\n```\n\n## A Simple Example\nIf you want to run the torchstat asap, you can call it as a CLI tool if your network exists in a script.\nOtherwise you need to import torchstat as a module.\n\n### CLI tool\n```bash\n$ torchstat masato$ torchstat -f example.py -m Net\n[MAdd]: Dropout2d is not supported!\n[Flops]: Dropout2d is not supported!\n[Memory]: Dropout2d is not supported!\n      module name  input shape output shape     params memory(MB)           MAdd         Flops  MemRead(B)  MemWrite(B) duration[%]   MemR+W(B)\n0           conv1    3 224 224   10 220 220      760.0       1.85   72,600,000.0  36,784,000.0    605152.0    1936000.0      57.49%   2541152.0\n1           conv2   10 110 110   20 106 106     5020.0       0.86  112,360,000.0  56,404,720.0    504080.0     898880.0      26.62%   1402960.0\n2      conv2_drop   20 106 106   20 106 106        0.0       0.86            0.0           0.0         0.0          0.0       4.09%         0.0\n3             fc1        56180           50  2809050.0       0.00    5,617,950.0   2,809,000.0  11460920.0        200.0      11.58%  11461120.0\n4             fc2           50           10      510.0       0.00          990.0         500.0      2240.0         40.0       0.22%      2280.0\ntotal                                        2815340.0       3.56  190,578,940.0  95,998,220.0      2240.0         40.0     100.00%  15407512.0\n===============================================================================================================================================\nTotal params: 2,815,340\n-----------------------------------------------------------------------------------------------------------------------------------------------\nTotal memory: 3.56MB\nTotal MAdd: 190.58MMAdd\nTotal Flops: 96.0MFlops\nTotal MemR+W: 14.69MB\n```\n\nIf you're not sure how to use a specific command, run the command with the -h or –help switches.\nYou'll see usage information and a list of options you can use with the command.\n\n### Module\n```python\nfrom torchstat import stat\nimport torchvision.models as models\n\nmodel = models.resnet18()\nstat(model, (3, 224, 224))\n```\n\n## Features \u0026 TODO\n**Note**: These features work only nn.Module. Modules in torch.nn.functional are not supported yet.\n- [x] FLOPs\n- [x] Number of Parameters\n- [x] Total memory\n- [x] Madd(FMA)\n- [x] MemRead\n- [x] MemWrite\n- [ ] Model summary(detail, layer-wise)\n- [ ] Export score table\n- [ ] Arbitrary input shape\n\nFor the supported layers, check out [the details](./detail.md).\n\n\n## Requirements\n* Python 3.6+\n* Pytorch 0.4.0+\n* Pandas 0.23.4+\n* NumPy 1.14.3+\n\n## References\nThanks to @sovrasov for the initial version of flops computation, @ceykmc for the backbone of scripts.\n* [flops-counter.pytorch](https://github.com/sovrasov/flops-counter.pytorch)\n* [pytorch_model_summary](https://github.com/ceykmc/pytorch_model_summary)\n* [chainer_computational_cost](https://github.com/belltailjp/chainer_computational_cost)\n* [convnet-burden](https://github.com/albanie/convnet-burden).\n","funding_links":[],"categories":["Python","Pytorch \u0026 related libraries｜Pytorch \u0026 相关库","Pytorch \u0026 related libraries","实用工具"],"sub_categories":["Other libraries｜其他库:","Other libraries:"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSwall0w%2Ftorchstat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FSwall0w%2Ftorchstat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSwall0w%2Ftorchstat/lists"}