pytorch错误记录:TypeError: Cannot handle this data type: (1, 1, 64), |u1

经过测试:

pairwise_distance函数在pytorch1.7上的表现与pytorch1.10/pytorch1.11上有区别,代码如下

pytorch1.7上

feat_A的size是1,64,64,64,feat_B的size是1,64,64,64

出来应该size是1,1,64,64

而在pytorch1.10/pytorch1.11

出来的size是1,64,64,1

import torch.nn.functional as F

self.dist = F.pairwise_distance(self.feat_A, self.feat_B, keepdim=True)

直接导致了进一步的计算图像大小存不出来

image_pil = Image.fromarray(image_numpy)
  File "D:\software\Anaconda3\envs\pt3.8\lib\site-packages\PIL\Image.py", line 2815, in fromarray
    raise TypeError("Cannot handle this data type: %s, %s" % typekey) from e
TypeError: Cannot handle this data type: (1, 1, 64), |u1

解决方式只能是版本回退

猜你喜欢

转载自blog.csdn.net/qq_20373723/article/details/127444894
今日推荐