Skip to content

Commit

Permalink
Revert "Added SpatialAdaptiveMaxPooling"
Browse files Browse the repository at this point in the history
  • Loading branch information
soumith committed Jan 16, 2015
1 parent 44dffdc commit 04d931f
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 332 deletions.
28 changes: 2 additions & 26 deletions doc/convolution.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ A convolution is an integral that expresses the amount of overlap of one functio
* [SpatialSubSampling](#nn.SpatialSubSampling) : a 2D sub-sampling over an input image ;
* [SpatialMaxPooling](#nn.SpatialMaxPooling) : a 2D max-pooling operation over an input image ;
* [SpatialAveragePooling](#nn.SpatialAveragePooling) : a 2D average-pooling operation over an input image ;
* [SpatialAdaptiveMaxPooling](#nn.SpatialAdaptiveMaxPooling) : a 2D max-pooling operation which adapts its parameters dynamically such that the output is of fixed size ;
* [SpatialLPPooling](#nn.SpatialLPPooling) : computes the `p` norm in a convolutional manner on a set of input images ;
* [SpatialConvolutionMap](#nn.SpatialConvolutionMap) : a 2D convolution that uses a generic connection table ;
* [SpatialZeroPadding](#nn.SpatialZeroPadding) : padds a feature map with specified number of zeros ;
Expand Down Expand Up @@ -369,29 +368,6 @@ Applies 2D average-pooling operation in `kWxkH` regions by step size
`dWxdH` steps. The number of output features is equal to the number of
input planes.

<a name="nn.SpatialAdaptiveMaxPooling"/>
### SpatialAdaptiveMaxPooling ###

```lua
module = nn.SpatialAdaptiveMaxPooling(W, H)
```

Applies 2D max-pooling operation in an image such that the output is of
size `WxH`, for any input size. The number of output features is equal
to the number of input planes.

For an output of dimensions `(owidth,oheight)`, the indexes of the pooling
region `(j,i)` in the input image of dimensions `(iwidth,iheight)` are
given by:

```
x_j_start = floor((j /owidth) * iwidth)
x_j_end = ceil(((j+1)/owidth) * iwidth)
y_i_start = floor((i /oheight) * iheight)
y_i_end = ceil(((i+1)/oheight) * iheight)
```

<a name="nn.SpatialSubSampling"/>
### SpatialSubSampling ###

Expand Down Expand Up @@ -443,8 +419,8 @@ Applies a 2D up-sampling over an input image composed of several input planes. T
`forward(input)` is expected to be a 3D or 4D tensor (i.e. for 4D: `nBatchPlane x nInputPlane x height x width`). The number of output planes will be the same. The v dimension is assumed to be the second last dimension (i.e. for 4D it will be the 3rd dim), and the u dimension is assumed to be the last dimension.

The parameters are the following:
* `scale`: The upscale ratio. Must be a positive integer

* `scale`: The upscale ratio. Must be a positive integer

The up-scaling method is simple nearest neighbor, ie:

```lua
Expand Down
269 changes: 0 additions & 269 deletions generic/SpatialAdaptiveMaxPooling.c

This file was deleted.

5 changes: 0 additions & 5 deletions init.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,6 @@
#include "generic/SpatialAveragePooling.c"
#include "THGenerateFloatTypes.h"

#include "generic/SpatialAdaptiveMaxPooling.c"
#include "THGenerateFloatTypes.h"

#include "generic/VolumetricConvolution.c"
#include "THGenerateFloatTypes.h"

Expand Down Expand Up @@ -162,7 +159,6 @@ int luaopen_libnn(lua_State *L)
nn_FloatSpatialSubSampling_init(L);
nn_FloatSpatialMaxPooling_init(L);
nn_FloatSpatialAveragePooling_init(L);
nn_FloatSpatialAdaptiveMaxPooling_init(L);
nn_FloatVolumetricConvolution_init(L);
nn_FloatVolumetricMaxPooling_init(L);
nn_FloatMultiMarginCriterion_init(L);
Expand Down Expand Up @@ -202,7 +198,6 @@ int luaopen_libnn(lua_State *L)
nn_DoubleSpatialSubSampling_init(L);
nn_DoubleSpatialMaxPooling_init(L);
nn_DoubleSpatialAveragePooling_init(L);
nn_DoubleSpatialAdaptiveMaxPooling_init(L);
nn_DoubleVolumetricConvolution_init(L);
nn_DoubleVolumetricMaxPooling_init(L);
nn_DoubleMultiMarginCriterion_init(L);
Expand Down
1 change: 0 additions & 1 deletion init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ include('SpatialMaxPooling.lua')
include('SpatialMaxPoolingCUDA.lua')
include('SpatialLPPooling.lua')
include('SpatialAveragePooling.lua')
include('SpatialAdaptiveMaxPooling.lua')
include('TemporalConvolution.lua')
include('TemporalSubSampling.lua')
include('TemporalMaxPooling.lua')
Expand Down
31 changes: 0 additions & 31 deletions test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1678,37 +1678,6 @@ function nntest.SpatialAveragePooling()
mytester:assertTensorEq(gradInput, gradInput2, 0.000001, torch.typename(module) .. ' backward err (Batch) ')
end

function nntest.SpatialAdaptiveMaxPooling()
local from = math.random(1,5)
local ki = math.random(1,12)
local kj = math.random(1,12)
local ini = math.random(1,64)
local inj = math.random(1,64)

local module = nn.SpatialAdaptiveMaxPooling(ki,kj)
local input = torch.rand(from,ini,inj)

local err = jac.testJacobian(module, input)
mytester:assertlt(err, precision, 'error on state ')

local ferr, berr = jac.testIO(module, input)
mytester:asserteq(ferr, 0, torch.typename(module) .. ' - i/o forward err ')
mytester:asserteq(berr, 0, torch.typename(module) .. ' - i/o backward err ')

-- batch
local nbatch = math.random(2,5)
input = torch.rand(nbatch,from,ini,inj)
module = nn.SpatialAdaptiveMaxPooling(ki,kj)

local err = jac.testJacobian(module, input)
mytester:assertlt(err, precision, 'error on state (Batch) ')

local ferr, berr = jac.testIO(module, input)
mytester:asserteq(ferr, 0, torch.typename(module) .. ' - i/o forward err (Batch) ')
mytester:asserteq(berr, 0, torch.typename(module) .. ' - i/o backward err (Batch) ')

end

function nntest.SpatialLPPooling()
local fanin = math.random(1,4)
local osizex = math.random(1,4)
Expand Down

0 comments on commit 04d931f

Please sign in to comment.