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

Log.lua - github.com/torch/nn.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: fec46641f36a6cdfd005a329fef364ec7dbe2709 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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