Hi, I searched that I’d need to use clone() to avoid inplace operation issue.
So, I cloned pred_R_imgs but I still have error.
When I commented them out, error would disappear.
Why does clone() work in this case?
pred_R_imgs=Net(O_img_tc)
pred_R_imgs[pred_R_imgs.clone()==0.0]=0.0001
pred_R_imgs[pred_R_imgs.clone()==-0.0]=0.0001
I incorrectly used clone()
This made error disappear
pred_R_imgs=Net(O_img_tc)
pred_R_imgs.clone()[pred_R_imgs==0.0]=0.0001
pred_R_imgs.clone()[pred_R_imgs==-0.0]=0.0001
tom
(Thomas V)
December 4, 2018, 10:42am
3
Yes, but you haven’t changed pred_R_imgs
but only it’s clones.
What you likely want is something like
pred_R_imgs = torch.where(pred_R_imgs.abs()>1e-4 , pred_R_imgs, torch.tensor(1e-4))
Best regards
Thomas
1 Like
That’s helpful advice using torch.where() to change value.
Thanks a lot, Thomas.