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)

你可能感兴趣的:(pytorch知识宝典,深度学习,pytorch,神经网络)