Commit c7c2cb9f authored by Jiri Borovec's avatar Jiri Borovec

fix

parent 781b7187
This diff is collapsed.
......@@ -14,7 +14,7 @@ import os
import time
import traceback
import logging
import copy
import numpy as np
import matplotlib.pylab as plt
......@@ -24,12 +24,12 @@ import generate_dataset as gen_data
import dictionary_learning as dl
import ptn_disctionary as ptn_dict
import ptn_weights as ptn_weigth
import expt_apd_sta as exp_sta
import expt_apd
logger = logging.getLogger(__name__)
NB_THREADS = exp_sta.NB_THREADS
PATH_OUTPUT = exp_sta.PATH_OUTPUT
NB_THREADS = expt_apd.NB_THREADS
PATH_OUTPUT = expt_apd.PATH_OUTPUT
# REQURED FOR MPROC POOL
# ISSUE: cPickle.PicklingError: Can't pickle <type 'instancemethod'>: attribute lookup __builtin__.instancemethod failed
......@@ -78,16 +78,17 @@ def test_simple_show_case():
# logger.debug(uc)
def experiment_pipeline_alpe_showcase(path_out=PATH_OUTPUT):
def experiment_pipeline_alpe_showcase(path_in=expt_apd.SYNTH_PATH_APD,
path_out=PATH_OUTPUT):
""" an simple show case to prove that the particular steps are computed
:param path_out: str
:return:
"""
atlas = gen_data.dataset_create_atlas(path_base=exp_sta.SYNTH_PATH_APD)
atlas = gen_data.dataset_create_atlas(path_base=path_in)
# plt.imshow(atlas)
imgs, _ = gen_data.dataset_load_images(path_base=exp_sta.SYNTH_PATH_APD)
imgs, _ = gen_data.dataset_load_images(path_base=path_in)
# imgs = gen_data.dataset_load_images('datasetBinary_defNoise',
# path_base=SYNTH_PATH_APD)
......@@ -96,12 +97,13 @@ def experiment_pipeline_alpe_showcase(path_out=PATH_OUTPUT):
init_atlas_msc = ptn_dict.initialise_atlas_mosaic(atlas.shape, np.max(atlas))
init_encode_rnd = ptn_weigth.initialise_weights_random(len(imgs), np.max(atlas))
atlas, w_bins = dl.alpe_pipe_atlas_learning_ptn_weights(imgs, out_prefix='mosaic',
init_atlas=init_atlas_msc, max_iter=9, out_dir=path_out)
atlas, w_bins = dl.alpe_pipe_atlas_learning_ptn_weights(imgs,
out_prefix='mosaic', init_atlas=init_atlas_msc,
max_iter=9, out_dir=path_out)
return atlas, w_bins
class ExperimentALPE(exp_sta.ExperimentAPD):
class ExperimentALPE(expt_apd.ExperimentAPD):
"""
the main experiment or our Atlas Learning Pattern Encoding
"""
......@@ -162,17 +164,17 @@ class ExperimentALPE(exp_sta.ExperimentAPD):
return stat
class ExperimentALPE_mp(ExperimentALPE, exp_sta.ExperimentAPD_mp):
class ExperimentALPE_mp(ExperimentALPE, expt_apd.ExperimentAPD_mp):
"""
parallel version of ALPE
"""
pass
def experiments_test():
def experiments_test(dict_params=expt_apd.SYNTH_PARAMS):
""" simple test of the experiments """
# experiment_pipeline_alpe_showcase()
params = exp_sta.SYNTH_PARAMS.copy()
params = copy.deepcopy(dict_params)
params['nb_runs'] = 3
logger.info('RUN: ExperimentALPE')
......@@ -184,26 +186,32 @@ def experiments_test():
expt_p.run(iter_var='case', iter_vals=range(params['nb_runs']))
def experiments_synthetic(dataset=None, nb_jobs=NB_THREADS):
def experiments_synthetic(dataset=None, nb_jobs=NB_THREADS,
dict_params=expt_apd.SYNTH_PARAMS,
sub_datasets=expt_apd.SYNTH_SUB_DATASETS,
ptn_range=expt_apd.SYNTH_PTN_RANGE,
ds_version=expt_apd.SYNTH_DATASET_VERSION):
""" run all experiments
:param dataset: str
:param dataset: str, name of dataset
:param nb_jobs: int
:param dict_params: {str: value}
:param sub_datasets: [str]
:param ptn_range: {str: [int]}
:param ds_version: str, version of dataset
"""
logging.basicConfig(level=logging.INFO)
params = exp_sta.SYNTH_PARAMS.copy()
params = copy.deepcopy(dict_params)
if type(dataset) is str:
params.update({'dataset': dataset})
l_params = [params]
l_params = exp_sta.extend_l_params(l_params, 'sub_dataset',
exp_sta.SYNTH_SUB_DATASETS)
l_params = exp_sta.extend_l_params(l_params, 'init_tp', ['msc', 'rnd'])
l_params = exp_sta.extend_l_params(l_params, 'ptn_split', [True, False])
range_nb_lbs = exp_sta.SYNTH_PTN_RANGE[exp_sta.SYNTH_DATASET_VERSION]
l_params = exp_sta.extend_l_params(l_params, 'nb_lbs', range_nb_lbs)
l_params = exp_sta.extend_l_params(l_params, 'gc_regul', [0., 1e-3, 1e-1, 1e0])
l_params = expt_apd.extend_l_params(l_params, 'sub_dataset', sub_datasets)
l_params = expt_apd.extend_l_params(l_params, 'init_tp', ['msc', 'rnd'])
l_params = expt_apd.extend_l_params(l_params, 'ptn_split', [True, False])
l_params = expt_apd.extend_l_params(l_params, 'nb_lbs', ptn_range[ds_version])
l_params = expt_apd.extend_l_params(l_params, 'gc_regul', [0., 1e-3, 1e-1, 1e0])
logger.debug('list params: %i', len(l_params))
......@@ -215,26 +223,28 @@ def experiments_synthetic(dataset=None, nb_jobs=NB_THREADS):
exp.run(iter_var='case', iter_vals=range(params['nb_runs']))
def experiments_real(dataset=None, nb_jobs=NB_THREADS):
def experiments_real(dataset=None, dict_params=expt_apd.REAL_PARAMS,
sub_datasets=expt_apd.REAL_SUB_DATASETS, nb_jobs=NB_THREADS):
""" run all experiments
:param dataset: str
:param nb_jobs: int
:param dict_params: {str: value}
:param sub_datasets: [str]
"""
logging.basicConfig(level=logging.INFO)
params = exp_sta.REAL_PARAMS.copy()
params = copy.deepcopy(dict_params)
if isinstance(dataset, str):
params.update({'dataset': dataset})
l_params = [params]
l_params = exp_sta.extend_l_params(l_params, 'sub_dataset',
exp_sta.REAL_SUB_DATASETS)
l_params = exp_sta.extend_l_params(l_params, 'init_tp', ['msc', 'rnd'])
l_params = exp_sta.extend_l_params(l_params, 'ptn_split', [True, False])
l_params = exp_sta.extend_l_params(l_params, 'nb_lbs',
l_params = expt_apd.extend_l_params(l_params, 'sub_dataset', sub_datasets)
l_params = expt_apd.extend_l_params(l_params, 'init_tp', ['msc', 'rnd'])
l_params = expt_apd.extend_l_params(l_params, 'ptn_split', [True, False])
l_params = expt_apd.extend_l_params(l_params, 'nb_lbs',
range(5, 12, 3) + range(12, 35, 5))
l_params = exp_sta.extend_l_params(l_params, 'gc_regul', [0., 1e-3, 1e-1, 1e0])
l_params = expt_apd.extend_l_params(l_params, 'gc_regul', [0., 1e-3, 1e-1, 1e0])
logger.debug('list params: %i', len(l_params))
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment