From 9c8f2bb5e53f2c4da64bf683c1255dada00fa255 Mon Sep 17 00:00:00 2001 From: asrata Date: Thu, 12 May 2016 16:10:29 -0400 Subject: [PATCH] Add gradInput nil check --- SplitTable.lua | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/SplitTable.lua b/SplitTable.lua index a47c580df..43b66a4fd 100644 --- a/SplitTable.lua +++ b/SplitTable.lua @@ -31,11 +31,13 @@ end function SplitTable:updateGradInput(input, gradOutput) local dimension = self:_getPositiveDimension(input) local slices = input:size(dimension) - self.gradInput:resizeAs(input) + if self.gradInput then + self.gradInput:resizeAs(input) - for i=1,slices do - local currentGradInput = gradOutput[i]; - self.gradInput:select(dimension,i):copy(currentGradInput) + for i=1,slices do + local currentGradInput = gradOutput[i]; + self.gradInput:select(dimension,i):copy(currentGradInput) + end end return self.gradInput end