MPRNet icon indicating copy to clipboard operation
MPRNet copied to clipboard

有大佬知道cuda:0 device type tensor to numpy怎么解决

Open xiaobai1feike opened this issue 2 years ago • 5 comments

can't convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.

xiaobai1feike avatar Feb 11 '23 10:02 xiaobai1feike

What exactly is the error

zhunzhun123 avatar Feb 15 '23 03:02 zhunzhun123

在tensor变量后面加.cpu()

MarkLi1214 avatar Mar 23 '23 20:03 MarkLi1214

i changed it in lines 120-121 :

 # Compute loss at each stage
        loss_char =  torch.sum(torch.stack([criterion_char(restored[j], target) for j in range(len(restored))]))
        loss_edge = torch.sum(torch.stack([criterion_edge(restored[j], target) for j in range(len(restored))]))
        loss = (loss_char) + (0.05*loss_edge)

and it's worked

jibrilhp avatar Jul 08 '23 16:07 jibrilhp

i changed it in lines 120-121 :

 # Compute loss at each stage
        loss_char =  torch.sum(torch.stack([criterion_char(restored[j], target) for j in range(len(restored))]))
        loss_edge = torch.sum(torch.stack([criterion_edge(restored[j], target) for j in range(len(restored))]))
        loss = (loss_char) + (0.05*loss_edge)

and it's worked

It works! Thank you!

wwwhaoyuuu avatar Oct 08 '23 12:10 wwwhaoyuuu

请问下改了这里之后你们训练会遇到损失降不下来的情况吗?我PSNR一直上不去,后面训练的都不如前面的很低很低,这是什么情况呢?

Feecuin avatar Mar 31 '24 14:03 Feecuin