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:
authorClement Farabet <clement.farabet@gmail.com>2012-04-01 18:45:20 +0400
committerClement Farabet <clement.farabet@gmail.com>2012-04-01 18:45:20 +0400
commit29cfb869afa0c3fe5545d92a1b978ddb754b2625 (patch)
tree9ca39051c499b09a6139444ffd294035696179c4 /Log.lua
parent6051e93dabb85f43df95cb3315776b6023dce4cc (diff)
Added Log module.
Diffstat (limited to 'Log.lua')
-rw-r--r--Log.lua20
1 files changed, 20 insertions, 0 deletions
diff --git a/Log.lua b/Log.lua
new file mode 100644
index 0000000..fec4664
--- /dev/null
+++ b/Log.lua
@@ -0,0 +1,20 @@
+local Log, parent = torch.class('nn.Log', 'nn.Module')
+
+function Log:__init(inputSize)
+ parent.__init(self)
+end
+
+function Log:updateOutput(input)
+ self.output:resizeAs(input)
+ self.output:copy(input)
+ self.output:log()
+ return self.output
+end
+
+function Log:updateGradInput(input, gradOutput)
+ self.gradInput:resizeAs(input)
+ self.gradInput:fill(1)
+ self.gradInput:cdiv(input)
+ self.gradInput:cmul(gradOutput)
+ return self.gradInput
+end