{"id":5523,"library":"torchinfo","title":"Torchinfo","description":"Torchinfo provides comprehensive model summaries for PyTorch, similar to TensorFlow's `model.summary()` API. It's a completely rewritten version of the original `torchsummary` and `torchsummaryX` projects, addressing previous issues and introducing a new API. It helps in debugging networks by visualizing layer details, input/output shapes, parameter counts, and operations. The current version is 1.8.0, and it follows an active release cadence with frequent updates.","status":"active","version":"1.8.0","language":"python","source_language":"en","source_url":"https://github.com/tyleryep/torchinfo","tags":["pytorch","model summary","deep learning","debugging","model analysis"],"install":[{"cmd":"pip install torchinfo","lang":"bash","label":"Install latest version"},{"cmd":"pip install 'torchinfo<1.6.0' # For Python 3.6 support","lang":"bash","label":"Install for Python 3.6"}],"dependencies":[{"reason":"Core PyTorch library for model definition and tensor operations.","package":"torch","optional":false}],"imports":[{"wrong":"from torchinfo import summary","symbol":"summary","correct":"from torchinfo import summary"}],"quickstart":{"code":"import torch\nimport torch.nn as nn\nfrom torchinfo import summary\n\nclass ConvNet(nn.Module):\n    def __init__(self):\n        super().__init__()\n        self.conv1 = nn.Conv2d(1, 10, kernel_size=5)\n        self.relu1 = nn.ReLU()\n        self.conv2 = nn.Conv2d(10, 20, kernel_size=5)\n        self.dropout = nn.Dropout2d()\n        self.relu2 = nn.ReLU()\n        self.fc1 = nn.Linear(320, 50)\n        self.fc2 = nn.Linear(50, 10)\n\n    def forward(self, x):\n        x = self.relu1(self.conv1(x))\n        x = nn.functional.max_pool2d(x, 2)\n        x = self.relu2(self.dropout(self.conv2(x)))\n        x = nn.functional.max_pool2d(x, 2)\n        x = x.view(-1, 320)\n        x = nn.functional.relu(self.fc1(x))\n        x = self.fc2(x)\n        return x\n\nmodel = ConvNet()\n# Example with input_size (batch_size, channels, height, width)\nsummary(model, input_size=(16, 1, 28, 28))\n\n# Example with input_data (for more complex forward passes)\n# dummy_input = torch.randn(16, 1, 28, 28)\n# summary(model, input_data=dummy_input)","lang":"python","description":"Initialize a PyTorch model and use `torchinfo.summary` to print its structure, parameter counts, input/output shapes, and other statistics. You can provide either `input_size` (a tuple representing the tensor shape, including batch size) or actual `input_data` (a tensor or sequence of tensors) for the model's forward pass."},"warnings":[{"fix":"Migrate to `pip install torchinfo` and update import statements to `from torchinfo import summary`.","message":"The `torch-summary` PyPI package has been renamed to `torchinfo`. While the old package might still exist, `torchinfo` is the actively maintained successor. Using `torch-summary` may lead to outdated features or lack of support.","severity":"breaking","affected_versions":"<1.6.0 (for torch-summary), all versions (for users attempting old package)"},{"fix":"Upgrade to Python 3.7+ or install a compatible older version like `pip install 'torchinfo<1.6.0'`.","message":"Python 3.6 support was deprecated in `torchinfo` v1.6.0. Users on Python 3.6 should install an older version of `torchinfo`.","severity":"deprecated","affected_versions":">=1.6.0"},{"fix":"Set your model to a consistent mode before calling `summary`, e.g., `model.eval()` or `model.train()`.","message":"Ensure your model's `train()` and `eval()` modes are consistent across layers when using `summary`. If layers are not all in the same mode, running `summary` may have unintended side effects on batch normalization or dropout statistics, as `torchinfo` performs a forward pass to gather information.","severity":"gotcha","affected_versions":"all"},{"fix":"Ensure your PyTorch version is 1.4.0 or newer. Check `torchinfo`'s release notes for compatibility with the latest PyTorch versions.","message":"`torchinfo` officially supports PyTorch versions 1.4.0 and higher. Using very old or very new (untested) PyTorch versions might lead to compatibility issues. Subsequent `torchinfo` releases (e.g., v1.7.1, v1.8.0) include updates for newer PyTorch versions like 1.12 and 2.0.","severity":"gotcha","affected_versions":"<1.4.0 (PyTorch), any version (potential for new PyTorch versions)"}],"env_vars":null,"search_vec":"'1.8.0':55 'activ':60 'address':28 'analysi':73 'api':14,35 'cadenc':62 'complet':18 'comprehens':4 'count':48 'current':52 'debug':39,71 'deep':69 'detail':44 'follow':58 'frequent':64 'help':37 'input/output':45 'introduc':32 'issu':30 'layer':43 'learn':70 'model':5,67,72 'model.summary':13 'network':40 'new':34 'oper':50 'origin':23 'paramet':47 'previous':29 'project':27 'provid':3 'pytorch':8,66 'releas':61 'rewritten':19 'shape':46 'similar':9 'summari':6,68 'tensorflow':11 'torchinfo':1,2 'torchsummari':24 'torchsummaryx':26 'updat':65 'version':20,53 'visual':42","created_at":"2026-04-14T01:37:30.610027+00:00","updated_at":"2026-04-16T14:13:53.840752+00:00","problems":{"verify_error":"Traceback (most recent call last):\n  File \"<string>\", line 1, in <module>\n  File \"/tmp/tmp70dzxrc9/venv/lib/python3.12/site-packages/torchinfo/__init__.py\", line 2, in <module>\n    from .model_statistics import ModelStatistics\n  File \"/tmp/tmp70dzxrc9/venv/lib/python3.12/site-packages/torchinfo/mode"},"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"1.8.0","cli_name":"torchinfo","cli_version":"sh: 1: torchinfo: not found","type":"library","homepage":null,"github":"https://github.com/tyleryep/torchinfo","docs":null,"changelog":null,"pypi":"https://pypi.org/project/torchinfo/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["ai-ml"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-07-03","last_verified":"2026-08-30","next_check":"2026-07-10","install_tag":null}}