graph.py 文件源码

python
阅读 40 收藏 0 点赞 0 评论 0

项目:ParlAI 作者: facebookresearch 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号