Commit 6c5cea9c authored by Jiri Borovec's avatar Jiri Borovec

add single and multi-thread for large image data

parent 03219a0e
......@@ -36,8 +36,8 @@ SYNTH_PARAMS = expt_apd.SYNTH_PARAMS
SYNTH_SUB_DATASETS = expt_apd.SYNTH_SUB_DATASETS
SYNTH_PTN_RANGE = expt_apd.SYNTH_PTN_RANGE
# expt_apd.ExperimentAPD_mp
class ExperimentLinearCombine(expt_apd.ExperimentAPD_mp):
class ExperimentLinearCombineBase(expt_apd.ExperimentAPD):
"""
State-of-te-Art methods that are based on Linear Combination
"""
......@@ -141,7 +141,7 @@ class ExperimentLinearCombine(expt_apd.ExperimentAPD_mp):
return stat
class ExperimentFastICA(ExperimentLinearCombine):
class ExperimentFastICA_base(ExperimentLinearCombineBase):
"""
http://scikit-learn.org/stable/modules/generated/sklearn.decomposition.FastICA.html
"""
......@@ -155,7 +155,7 @@ class ExperimentFastICA(ExperimentLinearCombine):
self.components = self.estimator.mixing_.T
class ExperimentSparsePCA(ExperimentLinearCombine):
class ExperimentSparsePCA_base(ExperimentLinearCombineBase):
"""
http://scikit-learn.org/stable/modules/generated/sklearn.decomposition.SparsePCA.html
"""
......@@ -168,7 +168,7 @@ class ExperimentSparsePCA(ExperimentLinearCombine):
self.components = self.estimator.components_
class ExperimentDictLearn(ExperimentLinearCombine):
class ExperimentDictLearn_base(ExperimentLinearCombineBase):
"""
http://scikit-learn.org/stable/modules/generated/sklearn.decomposition.DictionaryLearning.html
"""
......@@ -184,6 +184,19 @@ class ExperimentDictLearn(ExperimentLinearCombine):
self.components = self.estimator.components_
class ExperimentFastICA(ExperimentFastICA_base, expt_apd.ExperimentAPD_mp):
pass
class ExperimentSparsePCA(ExperimentSparsePCA_base, expt_apd.ExperimentAPD_mp):
pass
class ExperimentDictLearn(ExperimentDictLearn_base, expt_apd.ExperimentAPD_mp):
pass
# standard multiprocessing version
METHODS = {
'PCA': ExperimentFastICA,
'ICA': ExperimentSparsePCA,
......@@ -191,6 +204,14 @@ METHODS = {
'APDL': expt_apdl.ExperimentAPDL,
}
# working jut in single thread for pasiisng to image data to prtial jobs
METHODS_BASE = {
'PCA': ExperimentFastICA_base,
'ICA': ExperimentSparsePCA_base,
'DL': ExperimentDictLearn_base,
'APDL': expt_apdl.ExperimentAPDL_base,
}
def experiments_test(params=SYNTH_PARAMS):
""" simple test of the experiments
......@@ -230,6 +251,8 @@ def experiments_synthetic(params=SYNTH_PARAMS):
for m in params['methods']:
cls_expt = METHODS[m]
if params['nb_jobs'] <= 1:
cls_expt = METHODS_BASE[m]
tqdm_bar = tqdm.tqdm(total=len(l_params))
for params in l_params:
expt = cls_expt(params)
......
......@@ -115,7 +115,7 @@ DICT_ATLAS_INIT = {
}
class ExperimentALPE_raw(expt_apd.ExperimentAPD):
class ExperimentAPDL_base(expt_apd.ExperimentAPD):
"""
the main real experiment or our Atlas Learning Pattern Encoding
"""
......@@ -189,9 +189,9 @@ class ExperimentALPE_raw(expt_apd.ExperimentAPD):
return stat
class ExperimentAPDL(ExperimentALPE_raw, expt_apd.ExperimentAPD_mp):
class ExperimentAPDL(ExperimentAPDL_base, expt_apd.ExperimentAPD_mp):
"""
parallel version of ALPE
parallel version of APDL
"""
pass
......@@ -204,7 +204,7 @@ def experiments_test(dict_params=SYNTH_PARAMS):
params['nb_runs'] = 3
logging.info('RUN: ExperimentALPE_raw')
expt = ExperimentALPE_raw(params)
expt = ExperimentAPDL_base(params)
expt.run(iter_var='case', iter_vals=range(params['nb_runs']))
logging.info('RUN: ExperimentALPE_mp')
......@@ -250,7 +250,7 @@ def experiments_synthetic(params=SYNTH_PARAMS):
if params['nb_jobs'] > 1:
expt = ExperimentAPDL(params, params['nb_jobs'])
else:
expt = ExperimentALPE_raw(params)
expt = ExperimentAPDL_base(params)
expt.run(iter_var='case', iter_vals=range(params['nb_runs']))
# exp.run(iter_var='nb_labels', iter_vals=ptn_range)
del expt
......@@ -283,7 +283,7 @@ def experiments_real(params=REAL_PARAMS):
if params['nb_jobs'] > 1:
expt = ExperimentAPDL(params, params['nb_jobs'])
else:
expt = ExperimentALPE_raw(params)
expt = ExperimentAPDL_base(params)
# exp.run(gt=False, iter_var='case', iter_values=range(params['nb_runs']))
expt.run(gt=False, iter_var='nb_labels', iter_vals=NB_PATTERNS_REAL)
tqdm_bar.update(1)
......
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