Skip to content

Commit

Permalink
less cluttering tostring
Browse files Browse the repository at this point in the history
  • Loading branch information
szagoruyko committed May 30, 2015
1 parent 744d783 commit 12b2af1
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
5 changes: 5 additions & 0 deletions SpatialAveragePooling.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,8 @@ function SpatialAveragePooling:updateGradInput(input, gradOutput)
return self.gradInput
end
end

function SpatialAveragePooling:__tostring__()
return string.format('%s(%d,%d,%d,%d)', torch.type(self),
self.kW, self.kH, self.dW, self.dH)
end
10 changes: 6 additions & 4 deletions SpatialConvolution.lua
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,15 @@ function SpatialConvolution:type(type)
end

function SpatialConvolution:__tostring__()
local s = string.format('%s(in: %d, out: %d, kW: %d, kH: %d', torch.type(self),
local s = string.format('%s(%d -> %d, %dx%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)
s = s .. string.format(', %d,%d', self.dW, self.dH)
end
if self.padding ~= 0 then
s = s .. ', padding: ' .. self.padding
if self.padding and self.padding ~= 0 then
s = s .. ', ' .. self.padding .. ',' .. self.padding
elseif self.pad_w or self.pad_h then
s = s .. ', ' .. self.pad_w .. ',' .. self.pad_h
end
return s .. ')'
end
10 changes: 6 additions & 4 deletions SpatialConvolutionMM.lua
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,15 @@ function SpatialConvolutionMM:type(type)
end

function SpatialConvolutionMM:__tostring__()
local s = string.format('%s(in: %d, out: %d, kW: %d, kH: %d', torch.type(self),
local s = string.format('%s(%d -> %d, %dx%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)
s = s .. string.format(', %d,%d', self.dW, self.dH)
end
if self.padding ~= 0 then
s = s .. ', padding: ' .. self.padding
if self.padding and self.padding ~= 0 then
s = s .. ', ' .. self.padding .. ',' .. self.padding
elseif self.pad_w or self.pad_h then
s = s .. ', ' .. self.pad_w .. ',' .. self.pad_h
end
return s .. ')'
end
2 changes: 1 addition & 1 deletion SpatialMaxPooling.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ function SpatialMaxPooling:empty()
end

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

0 comments on commit 12b2af1

Please sign in to comment.