-function DAG:setInput(i)
- self.sorted = nil
- if torch.type(i) == 'table' then
- self.inputModules = i
- for _, m in ipairs(i) do
- if not self.pred[m] and not self.succ[m] then
- self:add(m)
- end
+function DAG:applyOnModules(f, t1, t2)
+ if torch.type(t1) == 'table' then
+ local result = {}
+ for k, s in pairs(t1) do
+ result[k] = self:applyOnModules(f, s, t2 and t2[k])