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

github.com/torch/nn.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRonan Collobert <ronan@collobert.com>2012-01-25 17:55:20 +0400
committerRonan Collobert <ronan@collobert.com>2012-01-25 17:55:20 +0400
commit4df3893abd1b9f840f1d9a8c1859799ccbf941de (patch)
treee8a1e1cc1b6ea6e47855347b157eaf419fdb357b /Select.lua
initial revamp of torch7 tree
Diffstat (limited to 'Select.lua')
-rw-r--r--Select.lua20
1 files changed, 20 insertions, 0 deletions
diff --git a/Select.lua b/Select.lua
new file mode 100644
index 0000000..acf8e06
--- /dev/null
+++ b/Select.lua
@@ -0,0 +1,20 @@
+local Select, parent = torch.class('nn.Select', 'nn.Module')
+
+function Select:__init(dimension,index)
+ parent.__init(self)
+ self.dimension = dimension
+ self.index = index
+end
+
+function Select:updateOutput(input)
+ local output = input:select(self.dimension,self.index);
+ self.output:resizeAs(output)
+ return self.output:copy(output)
+end
+
+function Select:updateGradInput(input, gradOutput)
+ self.gradInput:resizeAs(input)
+ self.gradInput:zero()
+ self.gradInput:select(self.dimension,self.index):copy(gradOutput)
+ return self.gradInput
+end