def set_sampler(opt, sampling_algorithm, data_loader): if "beam" in sampling_algorithm: opt.eval.bs = int(sampling_algorithm.split("-")[1]) sampler = BeamSampler(opt, data_loader) elif "topk" in sampling_algorithm: opt.eval.k = int(sampling_algorithm.split("-")[1]) sampler = TopKSampler(opt, data_loader) else: sampler = GreedySampler(opt, data_loader) return sampler
def set_sampler(opt, sampling_algorithm, data_loader): if "beam" in sampling_algorithm: opt.eval.bs = int(sampling_algorithm.split("-")[1]) sampler = BeamSampler(opt, data_loader) elif "topk" in sampling_algorithm: # print("Still bugs in the topk sampler. Use beam or greedy instead") # raise NotImplementedError opt.eval.k = int(sampling_algorithm.split("-")[1]) sampler = TopKSampler(opt, data_loader) else: sampler = GreedySampler(opt, data_loader) return sampler