domainlab.exp package

Submodules

domainlab.exp.exp_cuda_seed module

Random seed should be set from command line to ensure reproducibility: https://pytorch.org/docs/stable/notes/randomness.html https://discuss.pytorch.org/t/difference-between-torch-manual-seed-and-torch-cuda-manual-seed/13848/6

domainlab.exp.exp_cuda_seed.set_seed(seed)[source]

domainlab.exp.exp_main module

experiment

class domainlab.exp.exp_main.Exp(args, task=None, model=None, observer=None, visitor=<class 'domainlab.exp.exp_utils.AggWriter'>)[source]

Bases: object

Exp is combination of Task, Algorithm, and Configuration (including random seed)

clean_up()[source]

to be called by a decorator

execute(num_epochs=None)[source]

train model check performance by loading persisted model

domainlab.exp.exp_utils module

This module contains 3 classes inheriting:

ExpProtocolAggWriter(AggWriter(ExpModelPersistVisitor))

class domainlab.exp.exp_utils.AggWriter(host)[source]

Bases: ExpModelPersistVisitor

  1. aggregate results to text file.

  2. all dependencies are in the constructor

confmat_to_file(confmat, confmat_filename)[source]

Save confusion matrix as a figure

Parameters:

confmat – confusion matrix.

first_line(dict_cols)[source]

generate header of the results aggregation file

get_cols()[source]

call the same function to always get the same columns configuration

get_fpath(dirname='aggrsts')[source]

for writing and reading, the same function is called to ensure name change in the future will not break the software

to_file(str_line)[source]
Parameters:

str_line

class domainlab.exp.exp_utils.ExpModelPersistVisitor(host)[source]

Bases: object

This class couples with Task class attributes

clean_up()[source]
load(suffix=None)[source]

load pre-defined model name from disk the save function is the same class so to ensure load will ways work

mk_model_na(tag=None, dd_cut=19)[source]
Parameters:

tag – for git commit hash for example

model_dir = 'saved_models'
model_suffix = '.model'
remove(suffix=None)[source]

remove model after use

save(model, suffix=None)[source]
Parameters:

model

class domainlab.exp.exp_utils.ExpProtocolAggWriter(host)[source]

Bases: AggWriter

AggWriter tailored to experimental protocol Output contains additionally index, exp task, te_d and params.

confmat_to_file(confmat, confmat_filename)[source]

Save confusion matrix as a figure

Parameters:

confmat – confusion matrix.

get_cols()[source]

columns

get_fpath(dirname=None)[source]

filepath

Module contents