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

test_connectivity.lua « test - github.com/torch/nngraph.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 99b2539519e7b040b3a24e17505efd9eeb86bc62 (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
local totem = require 'totem'
require 'nngraph'
local tests = totem.TestSuite()
local tester = totem.Tester()

function tests.connectivity()
  -- Store debug info here, need to call debug.getinfo on same line as the
  -- dangling pointer is declared.
  local dInfo
  local input = nn.Identity()()
  local lin = nn.Linear(20, 10)(input)
  -- The Sigmoid does not connect to the output, so should cause an error
  -- when we call gModule.
  local dangling = nn.Sigmoid()(lin); dInfo = debug.getinfo(1, 'Sl')
  local actualOutput = nn.Tanh()(lin)
  local errStr = string.format(
      'node declared on %%[%s%%]:%d_ does not connect to gmodule output',
      dInfo.short_src, dInfo.currentline)
  tester:assertErrorPattern(
      function()
        return nn.gModule({input}, {actualOutput})
      end,
      errStr)
end

return tester:add(tests):run()