from eICU_preprocessing.split_train_test import create_folder
from models.run_tpc import TPC
from models.initialise_arguments import initialise_tpc_arguments

if __name__ == '__main__':

    c = initialise_tpc_arguments()
    c['mode'] = 'test'
    c['exp_name'] = 'TempWeightShare'
    c['model_type'] = 'temp_only'
    c['share_weights'] = True
    c['temp_kernels'] = [32] * c['n_layers']

    log_folder_path = create_folder('models/experiments/final', c.exp_name)
    temp_weight_share = TPC(
        config=c,
        n_epochs=c.n_epochs,
        name=c.exp_name,
        base_dir=log_folder_path,
        explogger_kwargs={'folder_format': '%Y-%m-%d_%H%M%S{run_number}'})
    temp_weight_share.run()
Пример #2
0
from models.run_tpc import TPC
import numpy as np
from models.initialise_arguments import initialise_tpc_arguments
from captum.attr import IntegratedGradients
from torch import cat, ones

time_point = 23  # this means 24 hours because of python's indexing
batch_size = 2

if __name__ == '__main__':

    base_dir = 'models/experiments/final/TPC'
    exp_dir = 'models/experiments/final/TPC/2020-06-27_2048171'

    tpc = TPC(base_dir=base_dir,
              resume=exp_dir,
              resume_save_types=('model', 'simple', 'th_vars', 'results'))

    c = initialise_tpc_arguments()
    c['mode'] = 'test'
    c['exp_name'] = 'TPC'
    c['model_type'] = 'tpc'
    tpc.config = c

    tpc.setup()
    tpc._setup_internal()
    tpc.prepare()
    tpc.model.eval()

    ig = IntegratedGradients(tpc.model)
Пример #3
0
from eICU_preprocessing.split_train_test import create_folder
from models.run_tpc import TPC
from models.initialise_arguments import initialise_tpc_arguments
from models.final_experiment_scripts.best_hyperparameters import best_tpc

if __name__ == '__main__':

    c = initialise_tpc_arguments()
    c['exp_name'] = 'PointwiseOnly'
    c['dataset'] = 'eICU'
    c = best_tpc(c)
    c['model_type'] = 'pointwise_only'

    log_folder_path = create_folder('models/experiments/final/eICU/LoS',
                                    c.exp_name)

    pointwise_only = TPC(
        config=c,
        n_epochs=c.n_epochs,
        name=c.exp_name,
        base_dir=log_folder_path,
        explogger_kwargs={'folder_format': '%Y-%m-%d_%H%M%S{run_number}'})
    pointwise_only.run()
    importances = baseline_score - np.array(scores)
    return Bunch(importances_mean=np.mean(importances, axis=1),
                 importances_std=np.std(importances, axis=1),
                 importances=importances)


if __name__ == '__main__':

    time_point = 23  # this means 24 hours because of python's indexing
    batch_size = 2

    base_dir = 'models/experiments/final/TPC'
    exp_dir = 'models/experiments/final/TPC/2020-06-27_2048171'

    tpc = TPC(base_dir=base_dir,
              resume=exp_dir,
              resume_save_types=('model', 'simple', 'th_vars', 'results'))

    c = initialise_tpc_arguments()
    c['mode'] = 'test'
    c['exp_name'] = 'TPC'
    c['model_type'] = 'tpc'
    tpc.config = c

    tpc.setup()
    tpc._setup_internal()
    tpc.prepare()
    tpc.model.eval()

    test_batches = tpc.test_datareader.batch_gen(batch_size=batch_size)
    ig = IntegratedGradients(tpc.model)