コード例 #1
0
def run_flat_gradient(model_path, drop_list=None):
    mdata = c.ModelData(model_path)
    gpn = MoTypes(False).network_model()
    gpn.load(mdata.ModelDefinition, mdata.LastCheckpoint)
    flt_params = GlobalDefs.circle_sim_params.copy()
    flt_params["t_max"] = flt_params["t_min"]
    sim = MoTypes(False).rad_sim(gpn, std, **flt_params)
    sim.t_max = sim.t_min  # reset gradient to be flat
    sim.remove = drop_list
    evo_path = model_path + '/evolve/generation_weights.npy'
    evo_weights = np.load(evo_path)
    w = np.mean(evo_weights[-1, :, :], 0)
    sim.bf_weights = w
    return sim.run_simulation(GlobalDefs.n_steps, False)
コード例 #2
0
ファイル: FigureS5.py プロジェクト: Kays3/GradientPrediction
 conn_mat = np.zeros((8, 8, len(paths_512_ce)))
 for i, p in enumerate(paths_512_ce):
     model_cids = clust_ids_ce[all_ids_ce[0, :] == i]
     layers_ids = all_ids_ce[1, :][all_ids_ce[0, :] == i]
     l_0_mask = np.full(8, False)
     ix = model_cids[layers_ids == 0]
     ix = ix[ix != -1]
     l_0_mask[ix] = True
     l_1_mask = np.full(8, False)
     ix = model_cids[layers_ids == 1]
     ix = ix[ix != -1]
     l_1_mask[ix] = True
     m_path = mpath(base_path_ce, p)
     mdata = c.ModelData(m_path)
     gpn = MoTypes(True).network_model()
     gpn.load(mdata.ModelDefinition, mdata.LastCheckpoint)
     input_result = gpn.parse_layer_input_by_cluster(
         't', 1, model_cids[layers_ids == 0], model_cids[layers_ids == 1])
     for k, l0 in enumerate(np.arange(8)[l_0_mask]):
         for l, l1 in enumerate(np.arange(8)[l_1_mask]):
             conn_mat[l0, l1, i] = input_result[k, l]
 # reordered version of conn_mat based on known types
 cm_order = [1, 7, 0, 2, 3, 4, 5, 6]
 cm_reordered = conn_mat[:, cm_order, :]
 cm_reordered = cm_reordered[cm_order, :, :]
 m = np.mean(cm_reordered, 2)
 s = np.std(cm_reordered, 2)
 cross_0 = np.sign((m + s) * (m - s)) <= 0
 m[cross_0] = 0
 s[cross_0] = 0
 fig, axes = pl.subplots(nrows=4, sharex=True, sharey=True)