← 开源
sksq96

pytorch-summary

Model summary in PyTorch similar to `model.summary()` in Keras

Model DevelopmentDeep Learning FrameworksPython
在 GitHub 打开
增长势头
+024 小时新增 Star0.0%
4.05k
Star
408
Fork
+0
本周
10
贡献者
创建于 2018-04-23 · 更新于 2026-10-15 · 今日第 7714 名
主要开发者
sksq96NaireenCoderx7

sksq96/pytorch-summary 排名第 7,714,有 4,050 个星标。

同类别比较

sksq96/pytorch-summary 排名第 7,714,此处有 8 个同类条目;kenshohara/3D-ResNets-PyTorch 排名第 7,716。

同类别比较
名称排名指标
google-deepmind/acme7,703
语言:
Python
星标数:
4,080
分叉数:
552
简介:
A library of reinforcement learning components and agents
facebookresearch/dlrm7,704
语言:
Python
星标数:
4,074
分叉数:
858
简介:
An implementation of a deep learning recommendation model (DLRM)
google-deepmind/learning-to-learn7,706
语言:
Python
星标数:
4,072
分叉数:
602
简介:
Learning to Learn in TensorFlow
FedML-AI/FedML7,707
语言:
Python
星标数:
4,070
分叉数:
768
简介:
FEDML - The unified and scalable ML library for large-scale distributed training, model serving, and federated learning. FEDML Launch, a cross-cloud scheduler, further enables running any AI jobs on any GPU cloud or on-premise cluster. Built on this library, TensorOpera AI (https://TensorOpera.ai) is your generative AI platform at scale.
kenshohara/3D-ResNets-PyTorch7,716
语言:
Python
星标数:
4,038
分叉数:
923
简介:
3D ResNets for Action Recognition (CVPR 2018)
MikeChongCan/scylla7,720
语言:
Python
星标数:
4,021
分叉数:
469
简介:
Intelligent proxy pool for Humans™ to extract content from the internet and build your own Large Language Models in this new AI era
buriburisuri/speech-to-text-wavenet7,724
语言:
Python
星标数:
4,005
分叉数:
785
简介:
Speech-to-Text-WaveNet : End-to-end sentence level English speech recognition based on DeepMind's WaveNet and tensorflow
neuraloperator/neuraloperator7,736
语言:
Python
星标数:
3,960
分叉数:
936
简介:
Learning in infinite dimension with neural operators.
关键参数与规格
关键参数与规格
参数值
语言Python
类别Model Development
子类别Deep Learning Frameworks
星标数4,050
分叉数408
贡献者10
创建日期2018-04-23
更新日期2026-10-15
1 天星标数0
7 天星标数0
排名7,714
上次排名4,916
排名变化-2,798
7 天星标排名11,791
上次 7 天星标排名11,848
7 天星标排名变化57
总星标排名3,424
上次总星标排名3,423
总星标排名变化-1
国家USA
README 摘录

Keras style in PyTorch Keras has a neat API to view the visualization of the model which is very helpful while debugging your network. Here is a barebone code to try and mimic the same in PyTorch. The aim is to provide information complementary to, what is not provided by in PyTorch. Usage or Note that the is required to make a forward pass through the network. Examples CNN for MNIST VGG16 Multiple Inputs References The idea for this package

sparked from this PyTorch issue. For Model Size Estimation @jacobkimmel (details here) License is MIT-licensed.

常见问题

记录了多少星标和分叉?

sksq96/pytorch-summary 有 4,050 个星标和 408 个分叉。

仓库排名是多少?

sksq96/pytorch-summary 排名第 7,714。

记录的语言和类别是什么?

sksq96/pytorch-summary 有 4,050 个星标,语言为 Python,类别为 Model Development。

哪个仓库排名最接近?

sksq96/pytorch-summary 与 kenshohara/3D-ResNets-PyTorch 比较,后者排名第 7,716,有 4,038 个星标。

README

Use the new and updated torchinfo.

Keras style model.summary() in PyTorch

Keras has a neat API to view the visualization of the model which is very helpful while debugging your network. Here is a barebone code to try and mimic the same in PyTorch. The aim is to provide information complementary to, what is not provided by print(your_model) in PyTorch.

Usage

  • pip install torchsummary or
  • git clone https://github.com/sksq96/pytorch-summary
from torchsummary import summary
summary(your_model, input_size=(channels, H, W))
  • Note that the input_size is required to make a forward pass through the network.

Examples

CNN for MNIST

import torch
import torch.nn as nn
import torch.nn.functional as F
from torchsummary import summary

class Net(nn.Module):
    def __init__(self):
        super(Net, self).__init__()
        self.conv1 = nn.Conv2d(1, 10, kernel_size=5)
        self.conv2 = nn.Conv2d(10, 20, kernel_size=5)
        self.conv2_drop = nn.Dropout2d()
        self.fc1 = nn.Linear(320, 50)
        self.fc2 = nn.Linear(50, 10)

    def forward(self, x):
        x = F.relu(F.max_pool2d(self.conv1(x), 2))
        x = F.relu(F.max_pool2d(self.conv2_drop(self.conv2(x)), 2))
        x = x.view(-1, 320)
        x = F.relu(self.fc1(x))
        x = F.dropout(x, training=self.training)
        x = self.fc2(x)
        return F.log_softmax(x, dim=1)

device = torch.device("cuda" if torch.cuda.is_available() else "cpu") # PyTorch v0.4.0
model = Net().to(device)

summary(model, (1, 28, 28))
----------------------------------------------------------------
        Layer (type)               Output Shape         Param #
================================================================
            Conv2d-1           [-1, 10, 24, 24]             260
            Conv2d-2             [-1, 20, 8, 8]           5,020
         Dropout2d-3             [-1, 20, 8, 8]               0
            Linear-4                   [-1, 50]          16,050
            Linear-5                   [-1, 10]             510
================================================================
Total params: 21,840
Trainable params: 21,840
Non-trainable params: 0
----------------------------------------------------------------
Input size (MB): 0.00
Forward/backward pass size (MB): 0.06
Params size (MB): 0.08
Estimated Total Size (MB): 0.15
----------------------------------------------------------------

VGG16

import torch
from torchvision import models
from torchsummary import summary

device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
vgg = models.vgg16().to(device)

summary(vgg, (3, 224, 224))
----------------------------------------------------------------
        Layer (type)               Output Shape         Param #
================================================================
            Conv2d-1         [-1, 64, 224, 224]           1,792
              ReLU-2         [-1, 64, 224, 224]               0
            Conv2d-3         [-1, 64, 224, 224]          36,928
              ReLU-4         [-1, 64, 224, 224]               0
         MaxPool2d-5         [-1, 64, 112, 112]               0
            Conv2d-6        [-1, 128, 112, 112]          73,856
              ReLU-7        [-1, 128, 112, 112]               0
            Conv2d-8        [-1, 128, 112, 112]         147,584
              ReLU-9        [-1, 128, 112, 112]               0
        MaxPool2d-10          [-1, 128, 56, 56]               0
           Conv2d-11          [-1, 256, 56, 56]         295,168
             ReLU-12          [-1, 256, 56, 56]               0
           Conv2d-13          [-1, 256, 56, 56]         590,080
             ReLU-14          [-1, 256, 56, 56]               0
           Conv2d-15          [-1, 256, 56, 56]         590,080
             ReLU-16          [-1, 256, 56, 56]               0
        MaxPool2d-17          [-1, 256, 28, 28]               0
           Conv2d-18          [-1, 512, 28, 28]       1,180,160
             ReLU-19          [-1, 512, 28, 28]               0
           Conv2d-20          [-1, 512, 28, 28]       2,359,808
             ReLU-21          [-1, 512, 28, 28]               0
           Conv2d-22          [-1, 512, 28, 28]       2,359,808
             ReLU-23          [-1, 512, 28, 28]               0
        MaxPool2d-24          [-1, 512, 14, 14]               0
           Conv2d-25          [-1, 512, 14, 14]       2,359,808
             ReLU-26          [-1, 512, 14, 14]               0
           Conv2d-27          [-1, 512, 14, 14]       2,359,808
             ReLU-28          [-1, 512, 14, 14]               0
           Conv2d-29          [-1, 512, 14, 14]       2,359,808
             ReLU-30          [-1, 512, 14, 14]               0
        MaxPool2d-31            [-1, 512, 7, 7]               0
           Linear-32                 [-1, 4096]     102,764,544
             ReLU-33                 [-1, 4096]               0
          Dropout-34                 [-1, 4096]               0
           Linear-35                 [-1, 4096]      16,781,312
             ReLU-36                 [-1, 4096]               0
          Dropout-37                 [-1, 4096]               0
           Linear-38                 [-1, 1000]       4,097,000
================================================================
Total params: 138,357,544
Trainable params: 138,357,544
Non-trainable params: 0
----------------------------------------------------------------
Input size (MB): 0.57
Forward/backward pass size (MB): 218.59
Params size (MB): 527.79
Estimated Total Size (MB): 746.96
----------------------------------------------------------------

Multiple Inputs

import torch
import torch.nn as nn
from torchsummary import summary

class SimpleConv(nn.Module):
    def __init__(self):
        super(SimpleConv, self).__init__()
        self.features = nn.Sequential(
            nn.Conv2d(1, 1, kernel_size=3, stride=1, padding=1),
            nn.ReLU(),
        )

    def forward(self, x, y):
        x1 = self.features(x)
        x2 = self.features(y)
        return x1, x2
    
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model = SimpleConv().to(device)

summary(model, [(1, 16, 16), (1, 28, 28)])
----------------------------------------------------------------
        Layer (type)               Output Shape         Param #
================================================================
            Conv2d-1            [-1, 1, 16, 16]              10
              ReLU-2            [-1, 1, 16, 16]               0
            Conv2d-3            [-1, 1, 28, 28]              10
              ReLU-4            [-1, 1, 28, 28]               0
================================================================
Total params: 20
Trainable params: 20
Non-trainable params: 0
----------------------------------------------------------------
Input size (MB): 0.77
Forward/backward pass size (MB): 0.02
Params size (MB): 0.00
Estimated Total Size (MB): 0.78
----------------------------------------------------------------

References

License

pytorch-summary is MIT-licensed.

排名相邻
同类项目