[英]Runtime error when using pytorch convolutional model
I'm trying to develop a covid-19 classification model.我正在尝试开发 covid-19 分类 model。 The images dataset I used is of shape torch.Size([100, 3, 224, 224]).
我使用的图像数据集的形状是 torch.Size([100, 3, 224, 224])。 When trying to run my model I'm getting this runtime error message(as shown in the image).
当尝试运行我的 model 时,我收到此运行时错误消息(如图所示)。 Any help to understand and fix the issue, please.
请帮助理解和解决问题。 this is the code
这是代码
class CovidCnnModel(ImageClassificationBase):
def __init__(self):
super().__init__()
self.network = nn.Sequential(
# nn.Conv2d(in_channels, out_channels, kernel_size =(3,3), padding=1),
nn.Conv2d(3, out_channels = 32, kernel_size=3, padding=1),
nn.ReLU(),
nn.Conv2d(32, 64, kernel_size=3, stride=1, padding=1),
nn.ReLU(),
nn.MaxPool2d(2, 2), # output: 64 x 16 x 16
nn.Conv2d(64, 128, kernel_size=3, stride=1, padding=1),
nn.ReLU(),
nn.Conv2d(128, 128, kernel_size=3, stride=1, padding=1),
nn.ReLU(),
nn.MaxPool2d(2, 2), # output: 128 x 8 x 8
nn.Conv2d(128, 256, kernel_size=3, stride=1, padding=1),
nn.ReLU(),
nn.Conv2d(256, 256, kernel_size=3, stride=1, padding=1),
nn.ReLU(),
nn.MaxPool2d(2, 2), # output: 256 x 4 x 4
nn.Flatten(),
nn.Linear(256*4*4, 1024),
nn.ReLU(),
nn.Linear(1024, 512),
nn.ReLU(),
nn.Linear(512, 2))
def forward(self, xb):
return self.network(xb)
Your input is of size 224x224
while your network is designed for ``128x128` (judging by the comments in the code).您的输入大小为
224x224
,而您的网络设计为“128x128”(根据代码中的注释判断)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.