Skip to content

Commit

Permalink
Merge pull request torch#265 from nicholas-leonard/SCFix
Browse files Browse the repository at this point in the history
SpatialConvolution empty gradParams fix
  • Loading branch information
soumith committed May 16, 2015
2 parents 28bb486 + daf9b6c commit 167d034
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions SpatialConvolution.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 167d034

Please sign in to comment.