![](/img/trans.png)
[英]Runtime Error when converting Pytorch model to PyTorch jit script
[英]Runtime error when using pytorch convolutional model
我正在尝试开发 covid-19 分类 model。 我使用的图像数据集的形状是 torch.Size([100, 3, 224, 224])。 当尝试运行我的 model 时,我收到此运行时错误消息(如图所示)。 请帮助理解和解决问题。 这是代码
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)
您的输入大小为224x224
,而您的网络设计为“128x128”(根据代码中的注释判断)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.