From 7dc69291661dbdf731f0da2955e8fec5f288cbba Mon Sep 17 00:00:00 2001 From: Francois Fleuret Date: Sat, 14 Jan 2017 22:12:32 +0100 Subject: [PATCH] Added a check that all nodes are connected to the inputs. --- dagnn.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dagnn.lua b/dagnn.lua index 5921c05..67e113d 100755 --- a/dagnn.lua +++ b/dagnn.lua @@ -76,6 +76,10 @@ function DAG:putInOrder() end until nc == 0 + for _, nnm in pairs(self.modules) do + assert(distance[nnm], 'Some modules are not connected to inputs') + end + self.sorted = {} for m, d in pairs(distance) do table.insert(self.sorted, { distance = d, nnm = m }) @@ -143,7 +147,7 @@ function DAG:setInput(i) self:nestedApply( function(nnm) if #self.node[nnm].succ == 0 then - error('Input modules must have outgoing edges.') + error('Input modules must have outgoing edges.') end if #self.node[nnm].pred > 0 then error('Input modules cannot have incoming edges.') -- 2.20.1