File: JustElement.lua

package info (click to toggle)
lua-torch-nngraph 0~20170208-g3ed3b9b-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,976 kB
  • sloc: makefile: 8
file content (18 lines) | stat: -rw-r--r-- 480 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

local JustElement, parent = torch.class('nngraph.JustElement', 'nn.Module')
function JustElement:__init()
   self.gradInput = {}
end

-- The input is a table with one element.
-- The output the element from the table.
function JustElement:updateOutput(input)
   assert(#input == 1, "expecting one element")
   self.output = input[1]
   return self.output
end

function JustElement:updateGradInput(input, gradOutput)
   self.gradInput[1] = gradOutput
   return self.gradInput
end