Welcome to mirror list, hosted at ThFree Co, Russian Federation.

VolumetricAveragePooling.lua - github.com/torch/nn.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 146304a78fa9afa130455c9c3a235c47b551af04 (plain)
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
local VolumetricAveragePooling, parent = torch.class(
   'nn.VolumetricAveragePooling', 'nn.Module')

function VolumetricAveragePooling:__init(kT, kW, kH, dT, dW, dH)
   parent.__init(self)

   dT = dT or kT
   dW = dW or kW
   dH = dH or kH

   self.kT = kT
   self.kH = kH
   self.kW = kW
   self.dT = dT
   self.dW = dW
   self.dH = dH
end

function VolumetricAveragePooling:updateOutput(input)
   input.THNN.VolumetricAveragePooling_updateOutput(
      input:cdata(),
      self.output:cdata(),
      self.kT, self.kW, self.kH,
      self.dT, self.dW, self.dH,
      0, 0, 0,
      false, true
   )
   return self.output
end

function VolumetricAveragePooling:updateGradInput(input, gradOutput)
   input.THNN.VolumetricAveragePooling_updateGradInput(
      input:cdata(),
      gradOutput:cdata(),
      self.gradInput:cdata(),
      self.kT, self.kW, self.kH,
      self.dT, self.dW, self.dH,
      0, 0, 0,
      false, true
   )
   return self.gradInput
end

function VolumetricAveragePooling:empty()
   return parent.clearState(self)
end

function VolumetricAveragePooling:__tostring__()
   local s =  string.format('%s(%dx%dx%d, %d,%d,%d', torch.type(self),
                            self.kT, self.kW, self.kH, self.dT, self.dW, self.dH)
   if (self.padT or self.padW or self.padH) and
      (self.padT ~= 0 or self.padW ~= 0 or self.padH ~= 0) then
      s = s .. ', ' .. self.padT.. ',' .. self.padW .. ','.. self.padH
   end
   s = s .. ')'

   return s
end