简体   繁体   English

使用 pytorch 卷积 model 时出现运行时错误

[英]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.

相关问题 将 Pytorch 模型转换为 PyTorch jit 脚本时出现运行时错误 - Runtime Error when converting Pytorch model to PyTorch jit script 测试 U-Net 时出现 Pytorch model 运行时错误 - Pytorch model runtime error when testing U-Net 尝试加载 PyTorch Model 时出现大小不匹配运行时错误 - Size Mismatch Runtime Error When Trying to Load a PyTorch Model 使用anaconda安装PyTorch时,Conda运行时错误 - Conda Runtime error when installing PyTorch using anaconda 尝试在 pytorch 中使用经过训练的 FNN model 时出现运行时错误(mat1 和 mat2 ...) - getting an RunTime Error (mat1 and mat2…) when trying to use a trained FNN model in pytorch 在Keras中实现自定义卷积层 - 加载模型时出错 - Implementing custom convolutional layer in Keras - error when loading model 在本地计算机上运行 PyTorch model 时出现运行时错误 - Runtime error while running PyTorch model on local machine 尝试将 cuda 与 pytorch 一起使用时出现运行时错误 999 - Runtime error 999 when trying to use cuda with pytorch 从训练数据集 PyTorch 读取数据时出现运行时错误 - Runtime error when reading data from a training dataset PyTorch 同时加载tensorflow和pytorch模型时的运行时错误 - Runtime error when load tensorflow and pytorch models at the same time
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM