admin管理员组

文章数量:1611398

在使用pytorch中的torchvision.models.segmentation.fcn_resnet50进行获得已经训练好的预训练模型时,所得结果的输出给我提示说argument 'input' (position 1) must be Tensor, not collections.OrderedDict,说网络输出的结果是OrderedDict而不是Tensor。我想看一下这个有序字典的shape,又报错collections.OrderedDict' object has no attribute 'shape'。直译过来就是collections.OrderedDict对象没有shape这一属性,给我整的一脸蒙逼,直接调用的网络输出为什么不是tensor而是一个有序字典呢。

在国内找了好久没找到解决答案,于是就去谷歌上搜了一下找到了解决答案。这个网站(https://www.learnopencv/pytorch-for-beginners-semantic-segmentation-using-torchvision/)提供的教程里有这么一段话

The output of torchvision models is an OrderedDict and not a torch.Tensor
And in during inference (.eval() mode ) the output, which is an OrderedDict just has one key – out. This o

本文标签: 时报模型argumentPytorchInput