def setUp(self): args = parse_args(['-e', 'tests', '-c', '../configurations/config.ini']) init_config(args.config) configs = get_configurations('tests') assert(len(configs) == 1) global_vars.set_config(configs[0]) set_params_by_dataset('../configurations/dataset_params.ini')
def test_get_multiple_values(self): args = parse_args([ '-e', 'test_multiple_values', '-c', '../configurations/config.ini' ]) init_config(args.config) configs = get_configurations(args) assert (len(configs) == 12) for str_conf in [ 'cross_subject', 'num_conv_blocks', 'num_generations' ]: assert (str_conf in get_multiple_values(configs)) global_vars.set_config(configs[0])
def setUp(self): args = parse_args( ['-e', 'tests', '-c', '../configurations/config.ini']) init_config(args.config) configs = get_configurations(args.experiment) assert (len(configs) == 1) global_vars.set_config(configs[0]) global_vars.set('eeg_chans', 22) global_vars.set('num_subjects', 9) global_vars.set('input_time_len', 1125) global_vars.set('n_classes', 4) set_params_by_dataset() input_shape = (50, global_vars.get('eeg_chans'), global_vars.get('input_time_len')) class Dummy: def __init__(self, X, y): self.X = X self.y = y dummy_data = Dummy(X=np.ones(input_shape, dtype=np.float32), y=np.ones(50, dtype=np.longlong)) self.iterator = BalancedBatchSizeIterator( batch_size=global_vars.get('batch_size')) self.loss_function = F.nll_loss self.monitors = [ LossMonitor(), MisclassMonitor(), GenericMonitor('accuracy', acc_func), RuntimeMonitor() ] self.stop_criterion = Or([ MaxEpochs(global_vars.get('max_epochs')), NoDecrease('valid_misclass', global_vars.get('max_increase_epochs')) ]) self.naiveNAS = NaiveNAS(iterator=self.iterator, exp_folder='../tests', exp_name='', train_set=dummy_data, val_set=dummy_data, test_set=dummy_data, stop_criterion=self.stop_criterion, monitors=self.monitors, loss_function=self.loss_function, config=global_vars.config, subject_id=1, fieldnames=None, model_from_file=None)
from EEGNAS.data_preprocessing import get_train_val_test, get_ch_names from braindecode.torch_ext.util import set_random_seeds from EEGNAS_experiment import get_normal_settings, parse_args, get_configurations from naiveNAS import NaiveNAS from EEGNAS.models_generation import target_model from braindecode.torch_ext.util import np_to_var import numpy as np from torch import nn from braindecode.torch_ext.util import var_to_np import torch as th import matplotlib matplotlib.use('qt5agg') args = parse_args(['-e', 'tests', '-c', '../configurations/config.ini']) global_vars.init_config(args.config) configs = get_configurations(args.experiment) assert (len(configs) == 1) global_vars.set_config(configs[0]) subject_id = 1 low_cut_hz = 0 fs = 250 valid_set_fraction = 0.2 dataset = 'BCI_IV_2a' data_folder = '../data/' global_vars.set('dataset', dataset) set_params_by_dataset() global_vars.set('cuda', True) model_select = 'deep4' model_dir = '143_x_evolution_layers_cross_subject'
all_exps['dataset'].append(global_vars.get('dataset')) if global_vars.get('iterations'): all_exps['iteration'].append(global_vars.get('iterations')) else: all_exps['iteration'].append(1) all_exps['result'].append(run.result) all_exps['runtime'].append(strfdelta(run.stop_time - run.start_time, '{hours}:{minutes}:{seconds}')) all_exps['omniboard_id'].append(run._id) all_exps['machine'].append(platform.node()) all_exps['local_exp_name'].append(exp_name) return [lst[-1] for lst in all_exps.values()] if __name__ == '__main__': args = parse_args(sys.argv[1:]) init_config(args.config) data_folder = 'data/' low_cut_hz = 0 valid_set_fraction = 0.2 listen() exp_id = get_exp_id('results') exp_funcs = {'per_subject': per_subject_exp, 'leave_one_out': leave_one_out_exp, 'cross_subject': cross_subject_exp} experiments = args.experiment.split(',') all_exps = defaultdict(list) first_run = True for experiment in experiments: configurations = get_configurations(experiment, global_vars.configs) multiple_values = get_multiple_values(configurations)
def set_default_config(path): global_vars.init_config(path) configurations = get_configurations('default_exp', global_vars.configs) global_vars.set_config(configurations[0])
for segment in ['test']: FEATURE_VALUES[(global_vars.get('model_alias'), global_vars.get('explainer'), global_vars.get('iteration'), segment)] = res[segment] write_config(global_vars.config, f"{exp_folder}/config_{exp_name}.ini") LAST_EXP_FOLDER = exp_folder if __name__ == '__main__': configs = configparser.ConfigParser() configs.read('visualization_configurations/viz_config.ini') configurations = get_configurations(sys.argv[1], configs, set_exp_name=False) global_vars.init_config('configurations/config.ini') set_default_config('../configurations/config.ini') global_vars.set('cuda', True) exp_id = get_exp_id('results') multiple_values = get_multiple_values(configurations) prev_model_alias = None for index, configuration in enumerate(configurations): update_global_vars_from_config_dict(configuration) if index + 1 < global_vars.get('start_exp_idx'): continue if global_vars.get('model_alias') == 'nsga' and global_vars.get( 'explainer') == 'integrated_gradients': continue if global_vars.get('model_alias'): alias = global_vars.get('model_alias') global_vars.set('models_dir', MODEL_ALIASES[alias][0])