Skip to content

Commit

Permalink
Add more useful string description of layers.
Browse files Browse the repository at this point in the history
Adds:
 - pbb in Dropout and SpatialDropout
 - non default params in SpatialConvolution, SpatialConvonlutionMM, SpatialMaxPooling
  • Loading branch information
orian committed May 26, 2015
1 parent 1cca535 commit 4bc5508
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Dropout.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,7 @@ end
function Dropout:setp(p)
self.p = p
end

function Dropout:__tostring__()
return string.format('%s(%f)', torch.type(self), self.p)
end
12 changes: 12 additions & 0 deletions SpatialConvolution.lua
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,15 @@ function SpatialConvolution:type(type)
self.fgradInput = torch.Tensor()
return parent.type(self,type)
end

function SpatialConvolution:__tostring__()
local s = string.format('%s(in: %d, out: %d, kW: %d, kH: %d', torch.type(self),
self.nInputPlane, self.nOutputPlane, self.kW, self.kH)
if self.dW ~= 1 or self.dH ~= 1 then
s = s .. string.format(', dW: %d, dH: %d', self.dW, self.dH)
end
if self.padding ~= 0 then
s = s .. ', padding: ' .. self.padding
end
return s .. ')'
end
12 changes: 12 additions & 0 deletions SpatialConvolutionMM.lua
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,15 @@ function SpatialConvolutionMM:type(type)
self.fgradInput = torch.Tensor()
return parent.type(self,type)
end

function SpatialConvolutionMM:__tostring__()
local s = string.format('%s(in: %d, out: %d, kW: %d, kH: %d', torch.type(self),
self.nInputPlane, self.nOutputPlane, self.kW, self.kH)
if self.dW ~= 1 or self.dH ~= 1 then
s = s .. string.format(', dW: %d, dH: %d', self.dW, self.dH)
end
if self.padding ~= 0 then
s = s .. ', padding: ' .. self.padding
end
return s .. ')'
end
4 changes: 4 additions & 0 deletions SpatialDropout.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,7 @@ end
function SpatialDropout:setp(p)
self.p = p
end

function SpatialDropout:__tostring__()
return string.format('%s(%f)', torch.type(self), self.p)
end
5 changes: 5 additions & 0 deletions SpatialMaxPooling.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,8 @@ function SpatialMaxPooling:empty()
self.indices:resize()
self.indices:storage():resize(0)
end

function SpatialMaxPooling:__tostring__()
return string.format('%s(kW: %d, kH: %d, dW: %d, dH: %d)', torch.type(self),
self.kW, self.kH, self.dW, self.dH)
end

0 comments on commit 4bc5508

Please sign in to comment.