diff options
author | Clement Farabet <clement.farabet@gmail.com> | 2011-10-01 00:21:12 +0400 |
---|---|---|
committer | Clement Farabet <clement.farabet@gmail.com> | 2011-10-01 00:21:12 +0400 |
commit | f50fcafb4736c3106cfcdb3c1d87f8c04fde3be1 (patch) | |
tree | ad1aff8597273a2b0f026cb248a27cd397c93239 /SpatialMaxSampling.lua | |
parent | 1ed6ecfee94b48fd6a92bae3ef982a41a55c0fde (diff) |
Added SpatialMaxSampling module, for flexible competitive resampling.
Diffstat (limited to 'SpatialMaxSampling.lua')
-rw-r--r-- | SpatialMaxSampling.lua | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/SpatialMaxSampling.lua b/SpatialMaxSampling.lua new file mode 100644 index 0000000..670d44b --- /dev/null +++ b/SpatialMaxSampling.lua @@ -0,0 +1,26 @@ +local SpatialMaxSampling, parent = torch.class('nn.SpatialMaxSampling', 'nn.Module') + +function SpatialMaxSampling:__init(...) + parent.__init(self) + xlua.unpack_class( + self, {...}, 'nn.SpatialMaxSampling', + 'resample an image using max selection', + {arg='rwidth', type='number', help='ratio: owidth/iwidth'}, + {arg='rheight', type='number', help='ratio: oheight/iheight'}, + {arg='owidth', type='number', help='output width'}, + {arg='oheight', type='number', help='output height'} + ) + self.indices = torch.Tensor() +end + +function SpatialMaxSampling:forward(input) + self.oheight = self.oheight or self.rheight*input:size(2) + self.owidth = self.owidth or self.rwidth*input:size(3) + input.nn.SpatialMaxSampling_forward(self, input) + return self.output +end + +function SpatialMaxSampling:backward(input, gradOutput) + input.nn.SpatialMaxSampling_backward(self, input, gradOutput) + return self.gradInput +end |