Inception v3 输入图片尺寸大小

pytorch官网表示输入图片尺寸最少224,自己用Inception v3开始设置的size是224,

代码简单如下:

import torchvision.models as models
from torchsummary import summary
import torch
Incep = models.Inception3()
Incep.fc = nn.Linear(2048, 100)
summary(Incep,(3,224,224))
print(summary)

报错如下:

RuntimeError: Calculated padded input size per channel: (3 x 3). Kernel size: (5 x 5). Kernel size can't be greater than actual input size at /pytorch/aten/src/THNN/generic/SpatialConvolutionMM.c:48

大概意思计算到某一层的时候图片size是(3,3),这时Kernel size是(5,5),那肯定报错了

后来尝试修改为(299,299),正确了

代码:

summary(Incep,(3,299,299))

部分运行结果:

Total params: 25,317,164
Trainable params: 25,317,164
Non-trainable params: 0
----------------------------------------------------------------
Input size (MB): 1.02
Forward/backward pass size (MB): 224.22
Params size (MB): 96.58
Estimated Total Size (MB): 321.82

 

你可能感兴趣的:(工作日记)