diff options
author | Dominik Grewe <dominikg@google.com> | 2015-10-16 19:21:47 +0300 |
---|---|---|
committer | Dominik Grewe <dominikg@google.com> | 2015-10-16 19:42:21 +0300 |
commit | 815e7a4ed9cc1b641bd17efc0c7f4766b1a14e92 (patch) | |
tree | 730d13b249257d46a4ef4a31e401ec2eb582e44e | |
parent | ffe960f3ded4c8964fa2c9508cbd2264ce3c68b4 (diff) |
Initialize modules table after read if necessary.
-rw-r--r-- | gmodule.lua | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/gmodule.lua b/gmodule.lua index a5c7d91..a360d2f 100644 --- a/gmodule.lua +++ b/gmodule.lua @@ -393,6 +393,24 @@ function gModule:accGradParameters(input,gradOutput,lr) end end +function gModule:read(file) + local data = file:readObject() + for k, v in pairs(data) do + self[k] = v + end + + -- Initialize the modules table if necessary. + if not self.modules then + self.modules = {} + for _, node in ipairs(self.forwardnodes) do + if node.data.module then + table.insert(self.modules, node.data.module) + end + end + end +end + + function gModule:__tostring__() return self.name or torch.type(self) end |