TylerYep/torchinfo
View model summaries in PyTorch!
What it solves
PyTorch's default print(model) provides limited information about a network's architecture. torchinfo provides a detailed, formatted summary of a PyTorch model, similar to Keras/TensorFlow's model.summary(), which is essential for debugging and verifying the structure of neural networks.
How it works
The tool takes a PyTorch nn.Module and either a sample input size or actual input data. It performs a forward pass to track the shapes of tensors as they flow through the layers, calculating the number of parameters, output shapes, and the number of multiply-accumulate operations (Mult-Adds).
Who it’s for
Deep learning practitioners and researchers using PyTorch who need to visualize their model architecture, verify tensor shapes, and estimate the memory footprint of their models.
Highlights
- Comprehensive Metrics: Displays layer names, input/output shapes, parameter counts, and Mult-Adds.
- Flexible Input: Supports providing either the input shape (as a tuple/list) or actual input tensors, including multiple inputs with different data types.
- Advanced Architecture Support: Handles RNNs, LSTMs, recursive layers,
nn.Sequential, andnn.ModuleList. - Customizable Output: Allows users to configure column visibility, row settings, depth of nested layers to display, and verbosity levels.
- Memory Estimation: Calculates the estimated total size of the model, including input size, parameter size, and forward/backward pass size.
Related
- Project
- Project
- Project
- Project
- Project