ankurhanda / gvnn

gvnn: Geometric Vision with Neural Networks
445 stars 71 forks source link

access to nil value in updateGradInput of OpticalFlow2D.lua #13

Closed ruppeshnalwaya1993 closed 7 years ago

ruppeshnalwaya1993 commented 7 years ago

Hi, I am using OpticalFlow2D.lua in pix2pix framework. I use it at the very end of the generator network like this:

    local d8 = d7 - nn.ReLU(true) - nn.SpatialFullConvolution(ngf * 2, 2, 4, 4, 2, 2, 1, 1)
    local d8_transposed = d8 - nn.Transpose({3,4},{2,4})
    local flowGrid = d8_transposed - nn.OpticalFlow2DBHWD(height,width)
    local inp_transposed = input - nn.Transpose({3,4},{2,4})
    local o1 = {inp_transposed,flowGrid} - nn.BilinearSamplerBHWD() - nn.Transpose({2,4})
    netG = nn.gModule({input},{o1})

In the backward pass, I get the following error

transferring to gpu...
done
/home/msarkar/torch/install/bin/luajit: ...e/msarkar/torch/install/share/lua/5.1/cutorch/Tensor.lua:22: attempt to index local 'tensor' (a nil value)
stack traceback:
        ...e/msarkar/torch/install/share/lua/5.1/cutorch/Tensor.lua:22: in function 'typeAs'
        ...arkar/torch/install/share/lua/5.1/gvnn/OpticalFlow2D.lua:72: in function 'updateGradInput'
        .../msarkar/torch/install/share/lua/5.1/nngraph/gmodule.lua:420: in function 'neteval'
        .../msarkar/torch/install/share/lua/5.1/nngraph/gmodule.lua:454: in function 'updateGradInput'
        /home/msarkar/torch/install/share/lua/5.1/nn/Module.lua:31: in function 'backward'
        train.lua:307: in function 'opfunc'
        /home/msarkar/torch/install/share/lua/5.1/optim/adam.lua:37: in function 'adam'
        train.lua:357: in main chunk
        [C]: in function 'dofile'
        ...rkar/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:145: in main chunk
        [C]: at 0x00406670

I commented out the :typeAs(optical_flow) in updateGradInput of OpticalFlow2D.lua . This makes the backward to run smoothly. But I am not sure if this has any side effects. Could you please tell me the correct way to remove this problem?

ankurhanda commented 7 years ago

sorry about that it should be :typeAs(optic_flow) - I've pushed the changes and you should be able to run it now smoothly. Let me know if it still crashes.

ruppeshnalwaya1993 commented 7 years ago

Thanks. Now it works.