EasyTPP Model Runner Modules

class runner.Runner(runner_config, unique_model_dir=False, **kwargs)[source]

Bases: Registrable

Registrable Base Runner class.

__init__(runner_config, unique_model_dir=False, **kwargs)[source]

Initialize the base runner.

Parameters:
  • runner_config (RunnerConfig) – config for the runner.

  • unique_model_dir (bool, optional) – whether to give unique dir to save the model. Defaults to False.

static build_from_config(runner_config, unique_model_dir=False, **kwargs)[source]

Build up the runner from runner config.

Parameters:
  • runner_config (RunnerConfig) – config for the runner.

  • unique_model_dir (bool, optional) – whether to give unique dir to save the model. Defaults to False.

Returns:

the corresponding runner class.

Return type:

Runner

get_config()[source]
set_model_dir(model_dir)[source]
get_model_dir()[source]
train(train_loader=None, valid_loader=None, test_loader=None, **kwargs)[source]

Train the model.

Parameters:
  • train_loader (EasyTPP.DataLoader, optional) – data loader for train set. Defaults to None.

  • valid_loader (EasyTPP.DataLoader, optional) – data loader for valid set. Defaults to None.

  • test_loader (EasyTPP.DataLoader, optional) – data loader for test set. Defaults to None.

Returns:

_description_

Return type:

model

evaluate(valid_loader=None, **kwargs)[source]
gen(gen_loader=None, **kwargs)[source]
save_log()[source]

Save log to local files

save(model_dir=None, **kwargs)[source]
run(**kwargs)[source]

Start the runner.

Parameters:

**kwargs (dict) – optional params.

Returns:

the results of the process.

Return type:

EasyTPP.BaseModel, dict

class runner.TPPRunner(runner_config, unique_model_dir=False, **kwargs)[source]

Bases: Runner

Standard TPP runner

__init__(runner_config, unique_model_dir=False, **kwargs)[source]

Initialize the base runner.

Parameters:
  • runner_config (RunnerConfig) – config for the runner.

  • unique_model_dir (bool, optional) – whether to give unique dir to save the model. Defaults to False.

run_one_epoch(data_loader, phase)[source]

Run one complete epoch.

Parameters:
  • data_loader – data loader object defined in model runner

  • phase – enum, [train, dev, test]

Returns:

a dict of metrics