Commit e8ffa515 by Jiri Borovec

fix for list of datasets

parent 0cb4887e
......@@ -32,10 +32,11 @@ import src.own_utils.tool_experiments as tl_expt
def _reduce_method(m):
# REQURED FOR MPROC POOL
# ISSUE: cPickle.PicklingError:
# Can't pickle <type 'instancemethod'>: attribute lookup __builtin__.instancemethod failed
# http://stackoverflow.com/questions/25156768/cant-pickle-type-instancemethod-using-pythons-multiprocessing-pool-apply-a
""" REQURED FOR MPROC POOL
ISSUE: cPickle.PicklingError:
Can't pickle <type 'instancemethod'>: attribute lookup __builtin__.instancemethod failed
http://stackoverflow.com/questions/25156768/cant-pickle-type-instancemethod-using-pythons-multiprocessing-pool-apply-a
"""
if m.im_self is None:
return getattr, (m.im_class, m.im_func.func_name)
else:
......@@ -68,9 +69,8 @@ SYNTH_SUB_DATASETS = ['datasetBinary_raw',
'datasetBinary_defNoise']
SYNTH_PARAMS = DEFAULT_PARAMS.copy()
SYNTH_PARAMS.update({
'data_type': 'synthetic',
'path_in': SYNTH_PATH_APD,
'dataset': SYNTH_SUB_DATASETS[0],
'dataset': SYNTH_SUB_DATASETS,
'path_out': PATH_RESULTS,
})
SYNTH_PTN_RANGE = {
......@@ -93,9 +93,8 @@ REAL_SUB_DATASETS = [
]
REAL_PARAMS = DEFAULT_PARAMS.copy()
REAL_PARAMS.update({
'data_type': 'real',
'path_in': os.path.join(PATH_DATA_REAL, REAL_DATASET_NAME),
'dataset': REAL_SUB_DATASETS[0],
'dataset': REAL_SUB_DATASETS,
'path_out': PATH_RESULTS,
'max_iter': 50,
'nb_runs': 10})
......@@ -109,10 +108,10 @@ def create_args_parser(dict_params):
:return: object argparse<in, out, ant, name>
"""
parser = argparse.ArgumentParser()
parser.add_argument('-in', '--path_in', type=str, required=False,
parser.add_argument('-in', '--path_in', type=str, required=True,
help='path to the input image dataset',
default=dict_params['path_in'])
parser.add_argument('-out', '--path_out', type=str, required=False,
parser.add_argument('-out', '--path_out', type=str, required=True,
help='path to the output with experiment results',
default=dict_params['path_out'])
parser.add_argument('-tp', '--type', type=str, required=False,
......@@ -163,7 +162,7 @@ class ExperimentAPD(tl_expt.Experiment):
:param dict_params: {str: ...}
"""
if not 'name' in dict_params:
dict_params['name'] = '{}_{}_{}'.format(dict_params['data_type'],
dict_params['name'] = '{}_{}_{}'.format(dict_params['type'],
os.path.basename(dict_params['path_in']),
dict_params['dataset'])
if not os.path.exists(dict_params['path_out']):
......@@ -238,6 +237,8 @@ class ExperimentAPD(tl_expt.Experiment):
self.l_stat.append(stat)
logging.info('partial results: %s', repr(stat))
tqdm_bar.update(1)
# just partial export
self._evaluate()
def _perform_once(self, v):
""" perform single experiment
......
......@@ -241,8 +241,6 @@ def experiments_synthetic(params=SYNTH_PARAMS):
params.update(arg_params)
if not 'method' in params:
params['method'] = METHODS.keys()
if not 'dataset' in params:
params['dataset'] = SYNTH_SUB_DATASETS
l_params = [params]
if isinstance(params['dataset'], list):
......
......@@ -234,9 +234,6 @@ def experiments_synthetic(params=SYNTH_PARAMS):
for k, v in arg_params.iteritems()]))
params.update(arg_params)
if not 'dataset' in params:
params['dataset'] = SYNTH_SUB_DATASETS
l_params = [params]
if isinstance(params['dataset'], list):
l_params = expt_apd.extend_list_params(l_params, 'dataset', params['dataset'])
......@@ -258,7 +255,8 @@ def experiments_synthetic(params=SYNTH_PARAMS):
expt.run(iter_var='case', iter_vals=range(params['nb_runs']))
# exp.run(iter_var='nb_labels', iter_vals=ptn_range)
del expt
except: pass
except:
logging.error(traceback.format_exc())
tqdm_bar.update(1)
gc.collect(), time.sleep(1)
......@@ -275,6 +273,8 @@ def experiments_real(params=REAL_PARAMS):
params.update(arg_params)
l_params = [copy.deepcopy(params)]
if isinstance(params['dataset'], list):
l_params = expt_apd.extend_list_params(l_params, 'dataset', params['dataset'])
# l_params = expt_apd.extend_list_params(l_params, 'init_tp', ['msc', 'rnd'])
# l_params = expt_apd.extend_list_params(l_params, 'ptn_split', [True, False])
l_params = expt_apd.extend_list_params(l_params, 'gc_regul', GRAPHCUT_REGUL)
......
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