diff options
author | Soumith Chintala <soumith@fb.com> | 2015-11-27 23:39:58 +0300 |
---|---|---|
committer | Soumith Chintala <soumith@fb.com> | 2015-11-27 23:44:58 +0300 |
commit | f985780b6dfa90639a6cdb0daaf29aef4401bde8 (patch) | |
tree | c3d30ca559fdf8b66e80f2f555f8d4b375075084 /Identity.lua | |
parent | 706d35e7aa6f2d1d848f0ed3ef9f90a15b74ce62 (diff) |
fix backcompat for nn.Identity
Diffstat (limited to 'Identity.lua')
-rw-r--r-- | Identity.lua | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Identity.lua b/Identity.lua index 3d73f81..08cccb2 100644 --- a/Identity.lua +++ b/Identity.lua @@ -8,7 +8,17 @@ function Identity:__init() 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 + function Identity:updateOutput(input) + backCompatibility(self, input) if torch.isTensor(input) then self.tensorOutput:set(input) self.output = self.tensorOutput |