-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSpatialMaxPooling2.lua
More file actions
36 lines (28 loc) · 855 Bytes
/
SpatialMaxPooling2.lua
File metadata and controls
36 lines (28 loc) · 855 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
35
36
local SpatialMaxPooling2, parent = torch.class('nn.SpatialMaxPooling2', 'nn.Module')
function SpatialMaxPooling2:__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()
self.fixOutputSize = false
end
function SpatialMaxPooling2:updateOutput(input)
input.nn.SpatialMaxPooling2_updateOutput(self, input)
return self.output
end
function SpatialMaxPooling2:updateGradInput(input, gradOutput)
input.nn.SpatialMaxPooling2_updateGradInput(self, input, gradOutput)
return self.gradInput
end
function SpatialMaxPooling2: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