diff options
author | Michael 'myrhev' Mathieu <michael.mathieu@ens.fr> | 2012-03-14 00:30:50 +0400 |
---|---|---|
committer | Michael 'myrhev' Mathieu <michael.mathieu@ens.fr> | 2012-03-14 00:30:50 +0400 |
commit | 9b2fe5a296bb6d28d759988583749b700293737b (patch) | |
tree | 11e1358f4ffaf0f23f6c661b568df61b6c001a49 /SpatialMatching.lua | |
parent | c35797f6aeae0ab019a059e2955f0e990b65bd0c (diff) | |
parent | 9e800b3021f3736a0239476c248e3ff5b5040cc7 (diff) |
Reversed the dimensions of the output of SpatialMatching, and its arguments
Conflicts:
SpatialMatching.lua
Diffstat (limited to 'SpatialMatching.lua')
-rw-r--r-- | SpatialMatching.lua | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/SpatialMatching.lua b/SpatialMatching.lua index f74ed5e..17fbe0f 100644 --- a/SpatialMatching.lua +++ b/SpatialMatching.lua @@ -1,34 +1,32 @@ local SpatialMatching, parent = torch.class('nn.SpatialMatching', 'nn.Module') -function SpatialMatching:__init(maxw, maxh, full_output) +function SpatialMatching:__init(maxh, maxw, 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 if full_output == nil then full_output = false end - if full_output then self.full_output = 1 else self.full_output = 0 end + self.full_output = full_output + self.gradInput1 = torch.Tensor() + self.gradInput2 = torch.Tensor() end function SpatialMatching:updateOutput(input) -- input is a table of 2 inputs, each one being KxHxW -- 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) + self.output:resize(self.maxh, self.maxw, input[1]:size(2), input[1]:size(3)) input[1].nn.SpatialMatching_updateOutput(self, input[1], input[2]) return self.output end function SpatialMatching:updateGradInput(input, gradOutput) - -- TODO this is probably the wrong way - self.gradInput1 = torch.Tensor(input[1]:size()):zero() - self.gradInput2 = torch.Tensor(input[2]:size()):zero() + self.gradInput1:resize(input[1]:size()):zero() + self.gradInput2:resize(input[2]:size()):zero() input[1].nn.SpatialMatching_updateGradInput(self, input[1], input[2], gradOutput) self.gradInput = {self.gradInput1, self.gradInput2} return self.gradInput |