diff options
author | Adam Paszke <adam.paszke@gmail.com> | 2016-03-02 23:56:26 +0300 |
---|---|---|
committer | Adam Paszke <adam.paszke@gmail.com> | 2016-03-05 15:56:03 +0300 |
commit | b1cf092d84bb6bfdbb6442d13cc0900e3aea7109 (patch) | |
tree | 2a27da19f92bd6262d01abc3fd816c12f39fd7b5 /DepthConcat.lua | |
parent | 3a2a1b42e6e6c61addbf82f1efaa7b35c2a3144f (diff) |
Improve error handling
When an error occurs in some module, all containers up to the
topmost one will be printed now.
Also, removed zeroGradParameters from ConcatTable, because it was
no different from its parent's implementation.
Diffstat (limited to 'DepthConcat.lua')
-rw-r--r-- | DepthConcat.lua | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/DepthConcat.lua b/DepthConcat.lua index e1091fa..8ae8384 100644 --- a/DepthConcat.lua +++ b/DepthConcat.lua @@ -29,7 +29,7 @@ end function DepthConcat:updateOutput(input) local outs = {} for i=1,#self.modules do - local currentOutput = self.modules[i]:updateOutput(input) + local currentOutput = self:rethrowErrors(self.modules[i], i, 'updateOutput', input) outs[i] = currentOutput if i == 1 then self.size:resize(currentOutput:dim()):copy(currentOutput:size()) @@ -62,7 +62,7 @@ function DepthConcat:updateGradInput(input, gradOutput) for i,module in ipairs(self.modules) do local currentOutput = module.output local gradOutputWindow = self:windowNarrow(gradOutput, currentOutput, offset) - local currentGradInput = module:updateGradInput(input, gradOutputWindow) + local currentGradInput = self:rethrowErrors(module, i, 'updateGradInput', input, gradOutputWindow) if i==1 then self.gradInput:copy(currentGradInput) else @@ -79,7 +79,7 @@ function DepthConcat:accGradParameters(input, gradOutput, scale) for i,module in ipairs(self.modules) do local currentOutput = module.output local gradOutputWindow = self:windowNarrow(gradOutput, currentOutput, offset) - module:accGradParameters(input, gradOutputWindow, scale) + self:rethrowErrors(module, i, 'accGradParameters', input, gradOutputWindow, scale) offset = offset + currentOutput:size(self.dimension) end end @@ -92,7 +92,7 @@ function DepthConcat:backward(input, gradOutput, scale) for i,module in ipairs(self.modules) do local currentOutput = module.output local gradOutputWindow = self:windowNarrow(gradOutput, currentOutput, offset) - local currentGradInput = module:backward(input, gradOutputWindow) + local currentGradInput = self:rethrowErrors(module, i, 'backward', input, gradOutputWindow) if i==1 then self.gradInput:copy(currentGradInput) else @@ -108,7 +108,7 @@ function DepthConcat:accUpdateGradParameters(input, gradOutput, lr) for i,module in ipairs(self.modules) do local currentOutput = module.output local gradOutputWindow = self:windowNarrow(gradOutput, currentOutput, offset) - module:accUpdateGradParameters(input, gradOutputWindow, lr) + self:rethrowErrors(module, i, 'accUpdateGradParameters', input, gradOutputWindow, lr) offset = offset + currentOutput:size(self.dimension) end end |