Usage
pip install torchsummary
orgit 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. - example
from torchvision import models
import torchsummary as summary
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
vgg = models.vgg16().to(device)
summary(vgg,(3,224,224))
根据上述使用说明:
import torchvision.models as models
import torchsummary as summary
#自定义模型model
summary(model,(3,224,224))
报错:TypeError: 'module' object is not callable
解决方法:
summary.summary(model,(3,224,224))