From: Francois Fleuret Date: Sat, 14 Jan 2017 21:12:32 +0000 (+0100) Subject: Added a check that all nodes are connected to the inputs. X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=commitdiff_plain;h=7dc69291661dbdf731f0da2955e8fec5f288cbba;p=dagnn.git Added a check that all nodes are connected to the inputs. --- 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.')