(self, path)
| 79 | torch.save(self.state_dict(), path) |
| 80 | |
| 81 | def loadParameters(self, path): |
| 82 | selfState = self.state_dict() |
| 83 | loadedState = torch.load(path) |
| 84 | for name, param in loadedState.items(): |
| 85 | origName = name; |
| 86 | if name not in selfState: |
| 87 | name = name.replace("module.", "") |
| 88 | if name not in selfState: |
| 89 | print("%s is not in the model."%origName) |
| 90 | continue |
| 91 | if selfState[name].size() != loadedState[origName].size(): |
| 92 | sys.stderr.write("Wrong parameter length: %s, model: %s, loaded: %s"%(origName, selfState[name].size(), loadedState[origName].size())) |
| 93 | continue |
| 94 | selfState[name].copy_(param) |
no outgoing calls
no test coverage detected