最近在做superglue论文的复现.
参考GitHub上面的superglue训练方法:
(https://github.com/HeatherJiaZG/SuperGlue-pytorch)
但是在训练网络时遇到了以下报错:
pytorch RuntimeError: Expected object of scalar type Double but got scalar type Float for argument #1 'sensors'
这个问题的解决方法主要是参考了这个博客:[https://cloud.tencent.com/developer/ask/sof/1483010/answer/2029233]
pytorch框架对数据进行训练时,输入数据一般默认为float类型,所以可以通过调用.float()来转换你的输入张量。
我的解决方法是:
在train.py文件中将double改为float
同时在load_data.py中将下面的double改为float
if len(kp1) < 1 or len(kp2) < 1:
return{
# torch.double
'keypoints0': torch.zeros([0, 0, 2], dtype=torch.float),
'keypoints1': torch.zeros([0, 0, 2], dtype=torch.float),
'descriptors0': torch.zeros([0, 2], dtype=torch.float),
'descriptors1': torch.zeros([0,