mirror of
https://github.com/wassname/multifit.git
synced 2026-09-09 11:27:26 +08:00
26 lines
746 B
Python
26 lines
746 B
Python
from functools import wraps
|
|
|
|
import fire
|
|
from .pretrain_lm import LMHyperParams
|
|
from .train_clas import CLSHyperParams
|
|
|
|
class FireView:
|
|
def __init__(self, **kwargs):
|
|
for k,v in kwargs.items():
|
|
setattr(self, k, v)
|
|
|
|
class ULMFiT:
|
|
@wraps(LMHyperParams)
|
|
def lm(self, dataset_path, **changes):
|
|
changes['dataset_path'] = dataset_path
|
|
params = LMHyperParams(**changes)
|
|
return FireView(train=params.train_lm)
|
|
|
|
lm2 = LMHyperParams
|
|
@wraps(CLSHyperParams)
|
|
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__':
|
|
fire.Fire(ULMFiT()) |