aimerykong / predictive-filter-flow

Predictive Filter Flow for fully/self-supervised learning on various vision tasks
https://www.ics.uci.edu/~skong2/mgpff.html
140 stars 24 forks source link

some tensor modified by an inplace operation #5

Open zlw21gxy opened 5 years ago

zlw21gxy commented 5 years ago

image when I running training demo of mgpff with torch 1.0.1.post2 , ubuntu16.04, the problem pop out. I thing it is related to some slide operation in losses.py, I fix it by adding some clone() but adding batch of clone doesn't seems to be a proper way, any idea to replace this trick? vgrid[:,0,:,:] = 2.0*vgrid[:,0,:,:].clone()/max(W-1,1)-1.0 vgrid[:,1,:,:] = 2.0*vgrid[:,1,:,:].clone()/max(H-1,1)-1.0

aimerykong commented 5 years ago

I believe this can be re-written into tensor operation. For example, for the following -- vgrid[:,0,:,:] = 2.0vgrid[:,0,:,:]/max(W-1,1)-1.0 vgrid[:,1,:,:] = 2.0vgrid[:,1,:,:]/max(H-1,1)-1.0

One way is to construction a tensor with H and W as the denominator, denoted by T; then run something like -- vgrid = torch.dvi(2.0*vgrid, T)

I didn't encounter this problem at my side, perhaps this is due to different versions of pytorch. What I used is 0.4.1 as you can read in the notebook.