Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Any success in applying this to VGG model? #6

Open
sheikirfanbasha opened this issue May 18, 2017 · 0 comments
Open

Any success in applying this to VGG model? #6

sheikirfanbasha opened this issue May 18, 2017 · 0 comments

Comments

@sheikirfanbasha
Copy link

I have been trying to apply the logic of deconvolution to VGG model. But so far have no success. The following is the modified code:

   local feature_map = state.network.modules[state.network_table[currentId].i].output[1][filterNum]:clone()
   print("size of feature map is:")
   print(feature_map:size())
   state.network.modules[state.network_table[currentId].i].output[1]:fill(0)
   state.network.modules[state.network_table[currentId].i].output[1][filterNum]:copy(feature_map)

   --- Guided back-propogation of ReLU
   -- http://arxiv.org/pdf/1412.6806v3.pdf
   local currentGradOutput = state.network.modules[state.network_table[currentId].i].output
   local currentModule = state.network.modules[state.network_table[currentId].i]
   for i=state.network_table[currentId].i-1,1,-1 do
     print("previous model: "..state.network.modules[i].__typename) 
     local previousModule = state.network.modules[i]
     if currentModule.__typename =="nn.ReLU" then 
        currentGradOutput = currentModule:backward(previousModule.output, currentGradOutput)
        currentGradOutput = currentModule:forward(currentGradOutput)
     else
        currentGradOutput = currentModule:backward(previousModule.output, currentGradOutput)
     end
     currentModule.gradInput = currentGradOutput
     currentModule = previousModule
   end
   currentGradOutput = currentModule:backward(input_img, currentGradOutput)
   print(currentGradOutput:size())
   local gra = image.toDisplayTensor{input=currentGradOutput[1],
               zoom = 8}
   -- local fea = image.toDisplayTensor{input=feature_map,
   --             zoom = 8}
   image.save('vgg_deconv.png', gra)

Error

bad argument #5 to 'v' (2D or 4D weight tensor expected, but got: [] at /torch/extra/nn/lib/THNN/generic/SpatialConvolutionMM.c:15)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant