def load_graph(self, fname):
if fname != '':
path = os.path.join(self._opt['datapath'], 'graph_world2')
fname = path + '/' + fname + '.gw2'
else:
fname = self._save_fname
if not os.path.isfile(fname):
print("[graph file not found: " + fname + ']')
return
print("[loading graph: " + fname + ']')
members = [attr for attr in dir(self) if not callable(getattr(self, attr))
and (not attr.startswith("__")) and (attr.startswith("_"))]
with open(fname, 'rb') as read:
model = torch.load(read)
for m in members:
if m in model:
setattr(self, m, model[m])
else:
print("[ loading: " + m + " is missing in file ]")
self._save_fname = fname
评论列表
文章目录