if len(sys.argv) >= 8:
    kick_seed = int(sys.argv[7])


param = (dt, tSim, N, S, p, num_fact, p_fact,
         dzeta, a_pf,
         eps,
         f_russo, cm, a, U, w, tau_1, tau_2, tau_3_A,
         tau_3_B, g_A,
         beta, tau, t_0, g, random_seed, p_0, n_p, nSnap,
         russo2008_mode, muted_prop)

# Some data are saved using simple text. Others are stored using the
# pkl format, which enables to store any kind of data very easily
key = file_handling.get_key(param)
ksi_i_mu, delta__ksi_i_mu__k, J_i_j_k_l, _ = file_handling.load_network(key)
cue_mask = iteration.get_units_to_cue(cue, kick_seed,
                                      delta__ksi_i_mu__k, muted_prop)

# Time arrays
tS = np.arange(0, tSim, dt)
nT = tS.shape[0]
tSnap = np.linspace(0, tSim, nSnap)

# Debugging
analyseTime = False
analyseDivergence = False

# Plot parameters
lamb = []                       # Crossovers
transition_time = []
Exemple #2
0
# simulations = ['ff9fe40ed43a94577c1cc2fea6453bf0']

n_seeds = 1
key = simulations[0]

retrieved = file_handling.load_retrieved_several(n_seeds, key)
crossover = file_handling.load_crossover_several(n_seeds, key)
trans_time = file_handling.load_transition_time(0, key)[0]

(dt, tSim, N, S, p, num_fact, p_fact, dzeta, a_pf, eps, f_russo, cm,
 a, U, w, tau_1, tau_2, tau_3_A, tau_3_B, g_A, beta, tau, t_0, g,
 random_seed, p_0, n_p, nSnap, russo2008_mode, kick_prop) = \
            file_handling.load_parameters(key)

ksi_i_mu, delta__ksi_i_mu__k, J_i_j_k_l, \
    C_i_j = file_handling.load_network(key)

pair_crossovers = [[] for pair in range(p**2)]
previous = []
following = []
crossovers = []
C_as = []
C_ad = []
C_ai = []
C_0 = []

for seed in range(n_seeds):
    for ind_cue in range(p):
        for ind_trans in range(3, len(retrieved[seed][ind_cue]) - 1):
            pattA = retrieved[seed][ind_cue][ind_trans]
            pattB = retrieved[seed][ind_cue][ind_trans + 1]
Exemple #3
0
import sys
# Local modules
from parameters import dt, tSim, N, S, p, num_fact, p_fact, dzeta, a_pf, eps, \
    f_russo, cm, a, U, w, tau_1, tau_2, tau_3_A, tau_3_B, g_A, beta, tau, \
    t_0, g, random_seed, p_0, n_p, nSnap, russo2008_mode
import initialisation
import file_handling
import patterns

param = (dt, tSim, N, S, p, num_fact, p_fact, dzeta, a_pf, eps, f_russo, cm, a,
         U, w, tau_1, tau_2, tau_3_A, tau_3_B, g_A, beta, tau, t_0, g,
         random_seed, p_0, n_p, nSnap, russo2008_mode)

set_name = file_handling.get_pkl_name(param)

if not file_handling.network_exists(set_name):
    ksi_i_mu, delta__ksi_i_mu__k = patterns.get_uncorrelated()
    J_i_j_k_l = initialisation.hebbian_tensor(delta__ksi_i_mu__k)

    file_handling.save_parameters_pkl(param, set_name)
    file_handling.save_network(ksi_i_mu, delta__ksi_i_mu__k, J_i_j_k_l,
                               set_name, param)

ksi_i_mub, delta__ksi_i_mu__kb, J_i_j_k_lb = file_handling.load_network(
    set_name)
ksi_i_muc, delta__ksi_i_mu__kc, J_i_j_k_lc = file_handling.load_network(
    set_name)

print((ksi_i_mu == ksi_i_mub).all())
print((ksi_i_muc == ksi_i_mub).all())
def sig_fun(r_i_k):
    """Activity of units"""
    rMax = np.max(r_i_k)
    sig_i_k = np.exp(beta * (r_i_k - rMax + U_i[:, None]))
    Z_i = spread_active_inactive_states.dot(
        sum_active_inactive_states.dot(sig_i_k))
    sig_i_k = sig_i_k / Z_i
    return sig_i_k


for ii in range(15):
    print(ii)
    key = simulations[ii]
    [_, durations] = file_handling.load_text(key + '/metrics_cue_%d.txt' % 0)
    ksi_i_mu, delta__ksi_i_mu__k, _, C_i_j = file_handling.load_network(key)

    coact_pos = file_handling.load_coact_pos(0, key)
    coact_neg = file_handling.load_coact_neg(0, key)

    (dt, tSim, N, S, p, num_fact, p_fact, dzeta, a_pf, eps, f_russo,
     cm, a, U, w, tau_1, tau_2, tau_3_A, tau_3_B, g_A, beta, tau, t_0,
     g, random_seed, p_0, n_p, nSnap, russo2008_mode) = \
        file_handling.load_parameters(key)

    patt_vect = delta__ksi_i_mu__k.astype(float) - a / S
    factor = np.sqrt(N * a * (1 - a / S))
    patt_vect /= factor

    patt_corr = np.dot(np.transpose(patt_vect), patt_vect)
    M = np.dot(patt_vect, np.transpose(patt_vect))
# plt.ylim(0, 3200)
plt.legend()
plt.title(r'Latching length')
plt.ylabel(r'$l$')
plt.xlabel(r'$a_{pf}$')

plt.figure('C_as')
n_pairs = int(p * (p - 1) / 2)
n_apf = len(apf_values)
df = np.zeros((len(apf_values) * n_pairs, 2))
for ind_apf in range(len(apf_values)):
    apf = apf_values[ind_apf]
    key = np.array(simulations)[apf_s == apf][0]
    print(apf, key)
    ksi_i_mu, _, _ = file_handling.load_network(key)
    C1C2C0 = correlations.cross_correlations(ksi_i_mu)
    df[ind_apf * n_pairs:(ind_apf + 1) * n_pairs, 0] = apf
    df[ind_apf * n_pairs:(ind_apf + 1) * n_pairs, 1] = C1C2C0[:, 0]
sns.violinplot(x=df[:, 0], y=df[:, 1])
plt.xlabel(r'$a_{pf}$')
plt.ylabel(r'$C_{as}$')

plt.figure('C_ad')
n_pairs = int(p * (p - 1) / 2)
n_apf = len(apf_values)
df = np.zeros((len(apf_values) * n_pairs, 2))
for ind_apf in range(len(apf_values)):
    apf = apf_values[ind_apf]
    key = np.array(simulations)[apf_s == apf][0]
    print(apf, key)