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@gmail.com>2015-07-31 15:40:04 +0300
committerSoumith Chintala <soumith@gmail.com>2015-07-31 15:40:04 +0300
commitd5cb02d4df2e07f686e530130b9b310e6bf88213 (patch)
tree887aabadb04b930e54885b7f3ae0e3dd887d352d
parent9f8b17b088088b0978ed6fcac52ffd95f646acec (diff)
parentc4244d392988177a4d542f84d7fa720476cda252 (diff)
Merge pull request #337 from torch/seqfix
fixing Sequential.remove corner case
-rw-r--r--Sequential.lua9
1 files changed, 7 insertions, 2 deletions
diff --git a/Sequential.lua b/Sequential.lua
index 359a764..aead092 100644
--- a/Sequential.lua
+++ b/Sequential.lua
@@ -29,8 +29,13 @@ function Sequential:remove(index)
error"index out of range"
end
table.remove(self.modules, index)
- self.output = self.modules[#self.modules].output
- self.gradInput = self.modules[1].gradInput
+ if #self.modules > 0 then
+ self.output = self.modules[#self.modules].output
+ self.gradInput = self.modules[1].gradInput
+ else
+ self.output = torch.Tensor()
+ self.gradInput = torch.Tensor()
+ end
end
function Sequential:updateOutput(input)