forked from torch/nn
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSpatialMaxPooling.lua
More file actions
34 lines (27 loc) · 816 Bytes
/
SpatialMaxPooling.lua
File metadata and controls
34 lines (27 loc) · 816 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
local SpatialMaxPooling, parent = torch.class('nn.SpatialMaxPooling', 'nn.Module')
function SpatialMaxPooling:__init(kW, kH, dW, dH)
parent.__init(self)
dW = dW or kW
dH = dH or kH
self.kW = kW
self.kH = kH
self.dW = dW
self.dH = dH
self.indices = torch.Tensor()
end
function SpatialMaxPooling:updateOutput(input)
input.nn.SpatialMaxPooling_updateOutput(self, input)
return self.output
end
function SpatialMaxPooling:updateGradInput(input, gradOutput)
input.nn.SpatialMaxPooling_updateGradInput(self, input, gradOutput)
return self.gradInput
end
function SpatialMaxPooling:empty()
self.gradInput:resize()
self.gradInput:storage():resize(0)
self.output:resize()
self.output:storage():resize(0)
self.indices:resize()
self.indices:storage():resize(0)
end