Beispiel #1
0
def ensemble_errant_result(dataset, stage):
    result_path = make_ensemble_base_dir(dataset, stage) / 'result.cat2'
    if result_path.exists():
        result = ErrantCat2Result(None, None, result_path)
    else:
        result = None
    return result
Beispiel #2
0
 def write_test(self):
     base_dir = make_ensemble_base_dir(self.dataset, 'test')
     base_dir.mkdir(parents=True, exist_ok=True)
     checkpoint_path = get_ensemble_checkpoint_path(
         self.make_result_table())
     self.write(base_dir, checkpoint_path, self.test_buffer_size,
                self.test_source)
Beispiel #3
0
def make_ensemble_result(result_class, dataset, stage):
    base_dir = make_ensemble_base_dir(dataset, stage)
    result_path = base_dir / 'result.res'
    if result_path.exists():
        result = result_class(None, None, result_path)
    else:
        result = None
    return result
Beispiel #4
0
def test_rescore_errant_result(dataset):
    valid_lst = valid_rescore_errant_results(dataset)
    if len(valid_lst) > 0:
        lmil = int(max(valid_lst).l * 1000)
        result_path = make_ensemble_base_dir(dataset, 'test') / 'result.{}.cat2'.format(lmil)
        result = ErrantCat2Result(None, None, result_path)
    else:
        result = None
    return result
Beispiel #5
0
def show_test_rescore_result(dataset, valid_result_list_fn, test_result_class):
    valid_result_list = valid_result_list_fn(dataset, 'valid')
    if len(valid_result_list) > 0:
        valid_maximum = max(valid_result_list)
        best_l = valid_maximum.l
        best_lmil = int(best_l * 1000)
        result_path = make_ensemble_base_dir(
            dataset, 'test') / 'result.{}.res'.format(best_lmil)
        test_result = test_result_class(None, None, result_path, l=best_l)
        print('rescore (l={}): {}'.format(test_result.l, test_result.gleu))
Beispiel #6
0
def valid_rescore_errant_results(dataset):
    config = load_config()
    result_list = []
    for l in config['rescore']['lambda']:
        base_dir = make_ensemble_base_dir(dataset, 'valid')
        lmil = int(l * 1000)
        output = base_dir / 'result.{}.cat2'.format(lmil)
        if output.exists():
            result = ErrantCat2Result(None, None, output, l = l)
            result_list.append(result)
    return result_list
Beispiel #7
0
def make_rescore_result_list(result_class, dataset, stage):
    config = load_config()
    result_list = []
    for l in config['rescore']['lambda']:
        base_dir = make_ensemble_base_dir(dataset, stage)
        lmil = int(l * 1000)
        output = base_dir / 'result.{}.res'.format(lmil)
        if output.exists():
            result = result_class(None, None, output, l=l)
            result_list.append(result)
    return result_list
Beispiel #8
0
 def __call__(self):
     self.write(make_ensemble_base_dir(self.dataset, 'test'))
Beispiel #9
0
 def make(self):
     self.append_command(make_ensemble_base_dir(self.dataset, 'valid'))
     self.append_command(make_ensemble_base_dir(self.dataset, 'test'))
Beispiel #10
0
 def make(self):
     for l in self.config['rescore']['lambda']:
         lmil = int(l * 1000)
         base_dir = make_ensemble_base_dir(self.dataset, self.stage)
         code_path = base_dir / 'score.{}.sh'.format(lmil)
         self.append_command(base_dir, code_path=code_path)