teachers.py 文件源码

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

项目:ParlAI 作者: facebookresearch 项目源码 文件源码
def __init__(self, opt, data_loader=None, cands=None, shared=None, **kwargs):
        # super() call initiates stream in self.data by calling _load()
        super().__init__(opt, data_loader, cands, shared, **kwargs)
        self.cycle = kwargs['cycle'] if 'cycle' in kwargs else True
        if shared:
            # auxiliary instances hold pointer to main datastream (in self.data)
            self.reset_data = shared['reset']
            # Share datafile and data_loader for computing num_exs and num_eps
            self.datafile = shared['datafile']
            self.data_loader = shared['data_loader']
            if 'lock' in shared:
                self.lock = shared['lock']
        else:
            # main instance holds the stream and shares pointer to it
            self.data_loader = data_loader
            self.datafile = opt['datafile']
            self.reset_data = None
            self.is_reset = True
            if opt.get('numthreads', 1) > 1:
                print('WARNING: multithreaded steaming will process every '
                      'example numthreads times.')
                self.lock = Lock()
        self.entry_idx = 0
        self.next_episode = None
        self.num_eps = None
        self.num_exs = None
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号