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:
authorSoumith Chintala <soumith@fb.com>2015-11-27 23:39:58 +0300
committerSoumith Chintala <soumith@fb.com>2015-11-27 23:44:58 +0300
commitf985780b6dfa90639a6cdb0daaf29aef4401bde8 (patch)
treec3d30ca559fdf8b66e80f2f555f8d4b375075084 /Identity.lua
parent706d35e7aa6f2d1d848f0ed3ef9f90a15b74ce62 (diff)
fix backcompat for nn.Identity
Diffstat (limited to 'Identity.lua')
-rw-r--r--Identity.lua10
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