RuntimeError: value cannot be converted to type uint8_t without overflow:
解决:将图像数据归一化
img = img / 255
RuntimeError: Expected object of scalar type Double but got scalar type Float for argument #3 ‘mat1’ in call to th_addmm
解决:将输入数据转换为Double,即float32
def forward(self, x):
x = torch.tensor(x, dtype=torch.float32)#数据转换
out = self.conv(x)
out = out.view(out.size(0), 1080)
out = self.fc(out)
return out