diff options
author | Joao Felipe Santos <joao.eel@gmail.com> | 2015-11-28 01:43:15 +0300 |
---|---|---|
committer | Joao Felipe Santos <joao.eel@gmail.com> | 2015-11-28 01:43:15 +0300 |
commit | 24294e2a90fbdcfa03a12652e94d5927f3326f90 (patch) | |
tree | ab604833ba6260a523b59635b91676f7bcb52d08 /Identity.lua | |
parent | f985780b6dfa90639a6cdb0daaf29aef4401bde8 (diff) |
Revert to previous Identity.lua implementation
Diffstat (limited to 'Identity.lua')
-rw-r--r-- | Identity.lua | 34 |
1 files changed, 3 insertions, 31 deletions
diff --git a/Identity.lua b/Identity.lua index 08cccb2..088cc34 100644 --- a/Identity.lua +++ b/Identity.lua @@ -1,40 +1,12 @@ -local Identity, parent = torch.class('nn.Identity', 'nn.Module') - -function Identity:__init() - parent.__init(self) - self.tensorOutput = torch.Tensor{} - self.output = self.tensorOutput - self.tensorGradInput = torch.Tensor{} - self.gradInput = self.tensorGradInput -end - -local function backCompatibility(self, input) - if self.tensorOutput == nil then - self.tensorOutput = input.new{} - self.output = self.tensorOutput - self.tensorGradInput = torch.Tensor{} - self.gradInput = self.tensorGradInput - end -end +local Identity, _ = torch.class('nn.Identity', 'nn.Module') function Identity:updateOutput(input) - backCompatibility(self, input) - if torch.isTensor(input) then - self.tensorOutput:set(input) - self.output = self.tensorOutput - else - self.output = input - end + self.output = input return self.output end function Identity:updateGradInput(input, gradOutput) - if torch.isTensor(gradOutput) then - self.tensorGradInput:set(gradOutput) - self.gradInput = self.tensorGradInput - else - self.gradInput = gradOutput - end + self.gradInput = gradOutput return self.gradInput end |