diff options
author | soumith <soumith@fb.com> | 2015-07-31 15:39:20 +0300 |
---|---|---|
committer | soumith <soumith@fb.com> | 2015-07-31 15:39:20 +0300 |
commit | c4244d392988177a4d542f84d7fa720476cda252 (patch) | |
tree | 887aabadb04b930e54885b7f3ae0e3dd887d352d | |
parent | 9f8b17b088088b0978ed6fcac52ffd95f646acec (diff) |
fixing Sequential.remove corner case
-rw-r--r-- | Sequential.lua | 9 |
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) |