Ejemplo n.º 1
0
NUM_RUNS = 10
PLOT_LINE_WIDTH = 5.0
PLOT_MARKER_SIZE = 17.0
################################################################################

EVAL_SAVE_DIR = os.path.join(SAVE_DIR, 'exp_results')
if not os.path.isdir(EVAL_SAVE_DIR):
    os.mkdir(EVAL_SAVE_DIR)

# Load and save metadata leakages & importances
leakage_dict = collections.defaultdict(list)
monet_importances = [None] * NUM_RUNS
monet0_importances = [None] * NUM_RUNS
for exp_no in range(NUM_RUNS):
    exp_save_path = os.path.join(SAVE_DIR, str(exp_no))
    monet_importances[exp_no] = load_numpy_matrix(
        os.path.join(exp_save_path, 'monet_importances'))
    monet0_importances[exp_no] = load_numpy_matrix(
        os.path.join(exp_save_path, 'monet0_importances'))
    with open(os.path.join(exp_save_path, 'leakage_dict')) as f:
        for k, v in json.loads(f.read()).items():
            leakage_dict[k].append(v)

with open(os.path.join(EVAL_SAVE_DIR, 'metadata_importances'), 'w') as f:
    pr = functools.partial(print, file=f)
    pr('# monet0 importance mean/std')
    pr(numpy.array2string(numpy.mean(monet0_importances, axis=0)))
    pr(numpy.array2string(numpy.std(monet0_importances, axis=0)))
    pr('# monet importance mean/std')
    pr(numpy.array2string(numpy.mean(monet_importances, axis=0)))
    pr(numpy.array2string(numpy.std(monet_importances, axis=0)))
Ejemplo n.º 2
0
def load_weights_object(savedir):
    weights = {}
    for m_type in default_m_types:
        weights[m_type] = load_numpy_matrix(os.path.join(savedir, m_type))
    return weights
Ejemplo n.º 3
0
def load_weights_object(savedir, M_types=['E', 'W', 'Z', 'H1', 'H2']):
  weights = {}
  for M_type in M_types:
    weights[M_type] = load_numpy_matrix(os.path.join(savedir, M_type))
  return weights