Fix issue when running cls training from command line

This commit is contained in:
Piotr Czapla
2018-12-04 00:59:36 +01:00
parent 82c955ce6a
commit 35a5dcb75a
3 changed files with 5 additions and 3 deletions
+1 -1
View File
@@ -103,7 +103,7 @@ def test_ulmfit_fastai_bidir_end_to_end():
name=lm_name,
)
exp.train_lm(num_epochs=1)
exp2 = ulmfit.train_clas.CLSHyperParams.from_lm(test_data / 'imdb', exp.model_dir)
exp2 = ulmfit.train_clas.CLSHyperParams.from_lm(str(test_data / 'imdb'), str(exp.model_dir))
exp2.train_cls(num_lm_epochs=0, unfreeze=False, bs=4, )
def test_ulmfit_moses_fa_bidir_end_to_end():
+2 -2
View File
@@ -18,8 +18,8 @@ class ULMFiT:
lm2 = LMHyperParams
@wraps(CLSHyperParams)
def cls(self, dataset_path, baseon_path, **changes):
params = CLSHyperParams.from_lm(dataset_path, baseon_path, **changes)
def cls(self, dataset_path, base_lm_path, **changes):
params = CLSHyperParams.from_lm(dataset_path, base_lm_path, **changes)
return FireView(train=params.train_cls)
if __name__ == '__main__':
+2
View File
@@ -243,6 +243,8 @@ class LMHyperParams:
@classmethod
def from_lm(cls, dataset_path, base_lm_path, **kwargs) -> 'LMHyperParams':
base_lm_path = Path(base_lm_path)
dataset_path = Path(dataset_path)
with open(base_lm_path/'info.json', 'r') as f: d = json.load(f)
d['dataset_path'] = dataset_path
d['base_lm_path'] = base_lm_path