diff options
author | Michael 'myrhev' Mathieu <michael.mathieu@ens.fr> | 2012-03-10 11:12:52 +0400 |
---|---|---|
committer | Michael 'myrhev' Mathieu <michael.mathieu@ens.fr> | 2012-03-10 11:12:52 +0400 |
commit | b8d8c0b682eb146453fda721907a58dae4cb9335 (patch) | |
tree | eae756ba68644ece2e68f3de8f6c517e0231083c /SpatialMatching.lua | |
parent | 90503963e940a592205f66a704b3d1e96e894c2c (diff) |
Modified the comportment of SpatialMatching with full_output = false
Diffstat (limited to 'SpatialMatching.lua')
-rw-r--r-- | SpatialMatching.lua | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/SpatialMatching.lua b/SpatialMatching.lua index 10e0dc7..77632e3 100644 --- a/SpatialMatching.lua +++ b/SpatialMatching.lua @@ -1,33 +1,32 @@ local SpatialMatching, parent = torch.class('nn.SpatialMatching', 'nn.Module') function SpatialMatching:__init(maxw, maxh, full_output) + -- If full_output is false, output is computed on elements of the first input + -- for which all the possible corresponding elements exist in the second input + -- In addition, if full_output is set to false, the pixel (1,1) of the first input + -- is supposed to correspond to the pixel (maxh/2, maxw/2) of the second one + -- If align_inputs is set, input[2] is assumed to be large enough + -- (that is input[1]:size(1) <= inputs[1]:size(1) - maxh + 1, same for w) + -- TODO full_output == true and align_inputs == false is probably useless parent.__init(self) self.maxw = maxw or 11 self.maxh = maxh or 11 - full_output = full_output or false - if full_output then - self.full_output = 1 - else - self.full_output = 0 - end + full_output = full_output or true + if full_output then self.full_output = 1 else self.full_output = 0 end end function SpatialMatching:updateOutput(input) -- input is a table of 2 inputs, each one being KxHxW - if self.full_output == 1 then - self.output:resize(input[1]:size(2), input[1]:size(3), self.maxh, self.maxw) - else - self.output:resize(input[1]:size(2)-self.maxh+1, input[1]:size(3)-self.maxw+1, - self.maxh, self.maxw) - end + -- if not full_output, the 1st one is KxH1xW1 where H1 <= H-maxh+1, W1 <= W-maxw+1 + self.output:resize(input[1]:size(2), input[1]:size(3), self.maxh, self.maxw) input[1].nn.SpatialMatching_updateOutput(self, input[1], input[2]) return self.output end function SpatialMatching:updateGradInput(input, gradOutput) - -- todo this is probably wrong - self.gradInput1 = torch.Tensor():resizeAs(input[1]):zero() - self.gradInput2 = torch.Tensor():resizeAs(input[2]):zero() + -- TODO this is probably the wrong way + self.gradInput1 = torch.Tensor(input[1]:size()):zero() + self.gradInput2 = torch.Tensor(input[2]:size()):zero() input[1].nn.SpatialMatching_updateGradInput(self, input[1], input[2], gradOutput) self.gradInput = {self.gradInput1, self.gradInput2} return self.gradInput |