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 /CDivTable.lua
initial revamp of torch7 tree
Diffstat (limited to 'CDivTable.lua')
-rw-r--r--CDivTable.lua21
1 files changed, 21 insertions, 0 deletions
diff --git a/CDivTable.lua b/CDivTable.lua
new file mode 100644
index 0000000..f91d024
--- /dev/null
+++ b/CDivTable.lua
@@ -0,0 +1,21 @@
+
+local CDivTable, parent = torch.class('nn.CDivTable', 'nn.Module')
+
+function CDivTable:__init()
+ parent.__init(self)
+ self.gradInput = {}
+end
+
+function CDivTable:updateOutput(input)
+ self.output:resizeAs(input[1]):copy(input[1])
+ self.output:cdiv(input[2])
+ return self.output
+end
+
+function CDivTable:updateGradInput(input, gradOutput)
+ self.gradInput[1] = self.gradInput[1] or torch.Tensor()
+ self.gradInput[2] = self.gradInput[2] or torch.Tensor()
+ self.gradInput[1]:resizeAs(input[1]):copy(gradOutput):cdiv(input[2])
+ self.gradInput[2]:resizeAs(input[2]):zero():addcdiv(-1,self.gradInput[1],input[2]):cmul(input[1])
+ return self.gradInput
+end