def simulate(seed, dt):
    """
    simulate 10 progressive recall of the original
    pattern at different dt according to the STDP 
    rule found experimentally


    """
    ncells = 3000 # number of cells
    c = 0.5       # connection probability 
    a = 0.1       # activity of a pattern
    m = 50        # number of patterns to store
    g1 = 0.433    # slope of inhibitory component
    
    W = topology(ncells, c, seed)
    Z = Pattern(ncells, a)
    Y = generate(Z, m)

    J = clipped_Hebbian(Y, W)
    J = J*delta_t(dt)


    overlap = np.empty(10)
    X = Y[0] # initial pattern

    for i in range(10):
        h = np.inner(J.T, X)/float(ncells)
        spk_avg = np.mean(X)
        X = ( h < g1*spk_avg ).choose(1,0)
        overlap[i] = get_overlap(Z, X)

    return(overlap)
def recall(Z,J):
    """
    returns a 
    """
    # X = INCOMPLETE PATTERN
    X = np.zeros(ncells, dtype=int)
    # incomplete pattern 10% of valid firings b1=0.1
    similarity = int(ncells*a*0.1)
    X[:similarity] = 1

    # RECALL
    nrecall = 10
    
    overlap = np.empty(11, dtype=float)
    overlap[0] = get_overlap(Z, X) # first the pattern itself 

    for i in range(1, nrecall+1):
        h = np.inner(J.T, X)/float(ncells)
        spk_avg = np.mean(X)
        X = ( h < g1*spk_avg ).choose(1,0)
        overlap[i] = get_overlap(Z, X)

    return(overlap)
Esempio n. 3
0
myseed = int(sys.argv[1])  # read the first argument of the command
ncells = 3000
W = topology(n=ncells, c=0.5, seed=myseed)
Z = Pattern(n=ncells, a=0.1)
Y = generate(Z, m=50)

J = clipped_Hebbian(Y, W)  # 8.93 s


# Recall
X = Y[0]  # The initial state is exactly the same as the initial pattern

nrecall = 6
spikes = np.empty((nrecall, ncells))

X = Y[0]  # The initial state is exactly the same as the initial pattern
for i in range(6):  # progressive recall in 6 steps

    h = np.inner(J.T, X) / float(ncells)  # 86.8 ms per loop
    print("recall [%d]:" % i),
    spk_avg = np.mean(X)
    print("threshold = %f" % (0.433 * spk_avg)),
    X = (h < 0.433 * spk_avg).choose(1, 0)
    spikes[i] = X
    print("Firings: valid/spurious %d/%d" % (get_valid(Z, X), get_spurious(Z, X))),
    print("Overlap = %f" % get_overlap(Z, X))


raster_plot(spikes)