From 979eb196d8bed8aa5a0322183ed3a7691505d8c7 Mon Sep 17 00:00:00 2001 From: Piotr Czapla Date: Wed, 21 Nov 2018 18:46:05 +0100 Subject: [PATCH] Change the classfication training learning rate to the one that was working te best in my exp. on bidirectional clasification --- ulmfit/train_clas.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/ulmfit/train_clas.py b/ulmfit/train_clas.py index b4bc636..0976e1e 100644 --- a/ulmfit/train_clas.py +++ b/ulmfit/train_clas.py @@ -85,7 +85,7 @@ def new_train_clas(data_dir, lang='en', cuda_id=0, pretrain_name='wt103', model_ else: emb_sz, nh, nl = 400, 1150, 3 - lm_enc_finetuned = f"{lm_name}_{dataset}_{name}_enc" + lm_enc_finetuned = f"{lm_name}_{dataset}_{pretrain_name}_enc" if fine_tune and not (model_dir/f"{lm_enc_finetuned}.pth").exists(): print('Fine-tuning the language model...') learn = lm_learner( @@ -120,22 +120,23 @@ def new_train_clas(data_dir, lang='en', cuda_id=0, pretrain_name='wt103', model_ train = True if train: + learn.true_wd = False print("Starting classifier training") - learn.fit_one_cycle(1, 2e-2, moms=(0.8, 0.7), wd=1e-7) + learn.fit_one_cycle(1, 5e-2, moms=(0.8, 0.7), wd=1e-7) learn.freeze_to(-2) - learn.fit_one_cycle(1, slice(1e-2 / (2.6 ** 4), 1e-2), moms=(0.8, 0.7)) + learn.fit_one_cycle(1, slice(5e-2 / (2.6 ** 4), 5e-2), moms=(0.8, 0.7), wd=1e-7) learn.freeze_to(-3) - learn.fit_one_cycle(1, slice(5e-3 / (2.6 ** 4), 5e-3), moms=(0.8, 0.7)) + learn.fit_one_cycle(1, slice(5e-4 / (2.6 ** 4), 5e-4), moms=(0.8, 0.7), wd=1e-7) learn.unfreeze() - learn.fit_one_cycle(2, slice(1e-3 / (2.6 ** 4), 1e-3), moms=(0.8, 0.7)) + learn.fit_one_cycle(2, slice(1e-2 / (2.6 ** 4), 1e-2), moms=(0.8, 0.7), wd=1e-7) print(f"Saving models at {learn.path / learn.model_dir}") learn.save(f'{model_name}_{name}') - results['accuracy'] = learn.validate()[1] + results['accuracy'] = learn.metrics[-1][0] return results