From daf9b6caca19906059e05ae57d7dfd3be0c0d6a6 Mon Sep 17 00:00:00 2001 From: Nicholas Leonard Date: Thu, 14 May 2015 14:42:11 -0400 Subject: [PATCH] SpatialConvolution empty gradParams fix --- SpatialConvolution.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/SpatialConvolution.lua b/SpatialConvolution.lua index ac98d9d30..4a42b637f 100644 --- a/SpatialConvolution.lua +++ b/SpatialConvolution.lua @@ -73,12 +73,16 @@ end -- function to re-view the weight layout in a way that would make the MM ops happy local function viewWeight(self) self.weight = self.weight:view(self.nOutputPlane, self.nInputPlane * self.kH * self.kW) - self.gradWeight = self.gradWeight and self.gradWeight:view(self.nOutputPlane, self.nInputPlane * self.kH * self.kW) + if self.gradWeight and self.gradWeight:dim() > 0 then + self.gradWeight = self.gradWeight:view(self.nOutputPlane, self.nInputPlane * self.kH * self.kW) + end end local function unviewWeight(self) self.weight = self.weight:view(self.nOutputPlane, self.nInputPlane, self.kH, self.kW) - self.gradWeight = self.gradWeight and self.gradWeight:view(self.nOutputPlane, self.nInputPlane, self.kH, self.kW) + if self.gradWeight and self.gradWeight:dim() > 0 then + self.gradWeight = self.gradWeight:view(self.nOutputPlane, self.nInputPlane, self.kH, self.kW) + end end function SpatialConvolution:updateOutput(input)