{"id":16896685,"url":"https://github.com/jettify/pytorch-inspect","last_synced_at":"2025-03-22T09:31:48.061Z","repository":{"id":38551901,"uuid":"205083784","full_name":"jettify/pytorch-inspect","owner":"jettify","description":"torch-inspect -- collection of utility functions to inspect low level information of neural network for PyTorch","archived":false,"fork":false,"pushed_at":"2023-03-06T11:00:30.000Z","size":108,"stargazers_count":17,"open_issues_count":21,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-01T15:01:38.830Z","etag":null,"topics":["pytorch"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jettify.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGES.rst","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-08-29T04:58:59.000Z","updated_at":"2022-05-01T14:49:00.000Z","dependencies_parsed_at":"2024-10-28T13:05:50.747Z","dependency_job_id":"24bafaf5-78ad-4413-9a1d-b085f8ff0759","html_url":"https://github.com/jettify/pytorch-inspect","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jettify%2Fpytorch-inspect","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jettify%2Fpytorch-inspect/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jettify%2Fpytorch-inspect/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jettify%2Fpytorch-inspect/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jettify","download_url":"https://codeload.github.com/jettify/pytorch-inspect/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244198405,"owners_count":20414443,"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":["pytorch"],"created_at":"2024-10-13T17:32:41.891Z","updated_at":"2025-03-22T09:31:47.731Z","avatar_url":"https://github.com/jettify.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"torch-inspect\n=============\n.. image:: https://travis-ci.com/jettify/pytorch-inspect.svg?branch=master\n    :target: https://travis-ci.com/jettify/pytorch-inspect\n.. image:: https://codecov.io/gh/jettify/pytorch-inspect/branch/master/graph/badge.svg\n    :target: https://codecov.io/gh/jettify/pytorch-inspect\n.. image:: https://img.shields.io/pypi/pyversions/torch-inspect.svg\n    :target: https://pypi.org/project/torch-inspect\n.. image:: https://img.shields.io/pypi/v/torch-inspect.svg\n    :target: https://pypi.python.org/pypi/torch-inspect\n\n**torch-inspect** -- collection of utility functions to inspect low level information of neural network for PyTorch_\n\nFeatures\n========\n* Provides helper function ``summary`` that prints Keras style model summary.\n* Provides helper function ``inspect`` that returns object with network summary information for programmatic access.\n* RNN/LSTM support.\n* Library has tests and reasonable code coverage.\n\n\nSimple example\n--------------\n\n.. code:: python\n\n    import torch.nn as nn\n    import torch.nn.functional as F\n    import torch_inspect as ti\n\n    class SimpleNet(nn.Module):\n        def __init__(self):\n            super(SimpleNet, self).__init__()\n            self.conv1 = nn.Conv2d(1, 6, 3)\n            self.conv2 = nn.Conv2d(6, 16, 3)\n            self.fc1 = nn.Linear(16 * 6 * 6, 120)\n            self.fc2 = nn.Linear(120, 84)\n            self.fc3 = nn.Linear(84, 10)\n\n        def forward(self, x):\n            x = F.max_pool2d(F.relu(self.conv1(x)), (2, 2))\n            x = F.max_pool2d(F.relu(self.conv2(x)), 2)\n            x = x.view(-1, self.num_flat_features(x))\n            x = F.relu(self.fc1(x))\n            x = F.relu(self.fc2(x))\n            x = self.fc3(x)\n            return x\n\n        def num_flat_features(self, x):\n            size = x.size()[1:]\n            num_features = 1\n            for s in size:\n                num_features *= s\n            return num_features\n\n\n      net = SimpleNet()\n      ti.summary(net, (1, 32, 32))\n\n\nWill produce following output:\n\n.. code::\n\n   ----------------------------------------------------------------\n           Layer (type)               Output Shape         Param #\n   ================================================================\n               Conv2d-1           [100, 6, 30, 30]              60\n               Conv2d-2          [100, 16, 13, 13]             880\n               Linear-3                 [100, 120]          69,240\n               Linear-4                  [100, 84]          10,164\n               Linear-5                  [100, 10]             850\n   ================================================================\n   Total params: 81,194\n   Trainable params: 81,194\n   Non-trainable params: 0\n   ----------------------------------------------------------------\n   Input size (MB): 0.39\n   Forward/backward pass size (MB): 6.35\n   Params size (MB): 0.31\n   Estimated Total Size (MB): 7.05\n   ----------------------------------------------------------------\n\nFor programmatic access to network information there is ``inspect`` function:\n\n.. code:: python\n\n      info = ti.inspect(net, (1, 32, 32))\n      print(info)\n\n\n.. code::\n\n     [LayerInfo(name='Conv2d-1', input_shape=[100, 1, 32, 32], output_shape=[100, 6, 30, 30], trainable_params=60, non_trainable_params=0),\n      LayerInfo(name='Conv2d-2', input_shape=[100, 6, 15, 15], output_shape=[100, 16, 13, 13], trainable_params=880, non_trainable_params=0),\n      LayerInfo(name='Linear-3', input_shape=[100, 576], output_shape=[100, 120], trainable_params=69240, non_trainable_params=0),\n      LayerInfo(name='Linear-4', input_shape=[100, 120], output_shape=[100, 84], trainable_params=10164, non_trainable_params=0),\n      LayerInfo(name='Linear-5', input_shape=[100, 84], output_shape=[100, 10], trainable_params=850, non_trainable_params=0)]\n\n\nInstallation\n------------\nInstallation process is simple, just::\n\n    $ pip install torch-inspect\n\n\nRequirements\n------------\n\n* Python_ 3.6+\n* PyTorch_ 1.0+\n\n\nReferences and Thanks\n---------------------\nThis package is based on pytorch-summary_ and  PyTorch issue_ . Compared to\npytorch-summary_, *pytorch-inspect* has support of RNN/LSTMs, also provides programmatic\naccess to the network summary information. With a bit more modular structure and presence of tests\nit is easier to extend and support more features.\n\n\n.. _Python: https://www.python.org\n.. _PyTorch: https://github.com/pytorch/pytorch\n.. _pytorch-summary:  https://github.com/sksq96/pytorch-summary\n.. _issue:  https://github.com/pytorch/pytorch/issues/2001\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjettify%2Fpytorch-inspect","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjettify%2Fpytorch-inspect","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjettify%2Fpytorch-inspect/lists"}