原文链接:https://blog.csdn.net/qq_40369180/article/details/104896719

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
Logo

技术共进,成长同行——讯飞AI开发者社区

更多推荐