Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/clementfarabet/lua---nnx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael 'myrhev' Mathieu <michael.mathieu@ens.fr>2012-06-14 22:34:59 +0400
committerMichael 'myrhev' Mathieu <michael.mathieu@ens.fr>2012-06-14 22:34:59 +0400
commitbee7a2b96c80caafb78130f627097372489b7503 (patch)
treee159bf1c55f8496f0730641789720fd4f3ab54f8 /SpatialRadialMatching.lua
parent07562f3244cb7c85f71fb47be7d57a2a66c7fd98 (diff)
Add SpatialRadialMatching
Diffstat (limited to 'SpatialRadialMatching.lua')
-rw-r--r--SpatialRadialMatching.lua33
1 files changed, 33 insertions, 0 deletions
diff --git a/SpatialRadialMatching.lua b/SpatialRadialMatching.lua
new file mode 100644
index 0000000..440a651
--- /dev/null
+++ b/SpatialRadialMatching.lua
@@ -0,0 +1,33 @@
+local SpatialRadialMatching, parent = torch.class('nn.SpatialRadialMatching', 'nn.Module')
+
+function SpatialRadialMatching:__init(maxh)
+ -- 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
+ parent.__init(self)
+ self.maxh = maxh
+ self.gradInput1 = torch.Tensor()
+ self.gradInput2 = torch.Tensor()
+end
+
+function SpatialRadialMatching: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)
+ --if input[3] == nil then
+ -- input[3] = torch.LongTensor(input[1]:size(2), input[1]:size(3)):fill(1)
+ --end
+ --input[1].nn.SpatialRadialMatching_updateOutput(self, input[1], input[2], input[3])
+ input[1].nn.SpatialRadialMatching_updateOutput(self, input[1], input[2])
+ return self.output
+end
+
+function SpatialRadialMatching:updateGradInput(input, gradOutput)
+ self.gradInput1:resize(input[1]:size()):zero()
+ self.gradInput2:resize(input[2]:size()):zero()
+ --input[1].nn.SpatialRadialMatching_updateGradInput(self,input[1],input[2],gradOutput,input[3])
+input[1].nn.SpatialRadialMatching_updateGradInput(self,input[1],input[2],gradOutput)
+ self.gradInput = {self.gradInput1, self.gradInput2}
+ return self.gradInput
+end