Expected all tensors to be on the same device, but found at least two devices 问题解决

解决方法1:

报错代码:

anchor_points = self.anchor_points(samples).repeat(batch_size, 1, 1)
output_coord = regression + anchor_points

修改后代码:

anchor_points = self.anchor_points(samples).repeat(batch_size, 1, 1)
# decode the points as prediction
# output_coord = regression + anchor_points.to(regression.device)
解决方法2:
device = torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')
 
g = g.to(device)
 
model=model.to(device)

猜你喜欢

转载自blog.csdn.net/jacke121/article/details/124913414