Beispiel #1
0
x[0][0] = pettern0[0]
x[0][1] = pettern0[1]
x[0][2] = pettern0[2]
x[0][3] = pettern0[3]

wij = np.zeros((100, 100))

for i in range(100):
    for j in range(100):
        for p in range(4):
            wij[i][j] += (2 * x[0][p][i] - 1) * (2 * x[0][p][j] - 1)
        wij[i][j] = wij[i][j] / 4
process_bar = lab.ShowProcess(t, "ok")

for t in range(t):
    for n in range(4):
        for i in range(100):
            wij_some = 0
            for j in range(100):
                wij_some += wij[i][j] * x[t][n][j]
            ni[t + 1][n][i] = kf * ni[t][n][i] + wij_some
            ci[t + 1][n][i] = kr * ci[t][n][i] - ar * x[t][n][i] + a0
            x[t + 1][n][i] = lab.sigmoid(ni[t + 1][n][i] + ci[t + 1][n][i])
    lab.number_to_image(x[t][0], t)
    process_bar.show_process()
"""
lab.number_to_image(x[0][0],10001)
lab.number_to_image(x[0][1],10002)
lab.number_to_image(x[0][2],10003)
lab.number_to_image(x[0][3],10004)
"""
Beispiel #2
0
                        for s in range(100):
                                max_ci += abs(ni[t][n][s])

                        for j in range(100):
                                wij_some += wij[i][j]*x[t][n][j]
                        max_ci = max_ci/M
                        ni[t+1][n][i] = kf*ni[t][n][i] + wij_some
                        ci[t+1][n][i] = kr*ci[t][n][i] - ar*x[t][n][i] + a0
                
                        if ci[t+1][n][i] >= max_ci and t != 0:
                                ci[t+1][n][i] = max_ci
                        elif ci[t+1][n][i] <= -max_ci and t != 0:
                                ci[t+1][n][i] = -max_ci

                        x[t+1][n][i] = lab.sigmoid(ni[t+1][n][i]+ci[t+1][n][i])     
        lab.number_to_image(x[t][pattern],t)
        process_bar.show_process()  


"""
for i in range(4):
    lab.number_to_image(x[0][i], 1000 + i)

for i in range(4):
    sum = 0
    for j in range(100):
        sum += x[0][i][j]
    print(sum)

print(x[0][0])
Beispiel #3
0
for i in range(100):
    for j in range(100):
        for p in range(4):
            wij[i][j] += (2 * x[0][p][i] - 1) * (2 * x[0][p][j] - 1)
        wij[i][j] = wij[i][j] / 4

for t in range(t):
    for n in range(4):
        for i in range(100):
            wij_some = 0
            max_ci = 0

            for s in range(100):
                max_ci += abs(ni[t][n][s])

            for j in range(100):
                wij_some += wij[i][j] * x[t][n][j]
            max_ci = max_ci / M
            ni[t + 1][n][i] = kf * ni[t][n][i] + wij_some
            ci[t + 1][n][i] = kr * ci[t][n][i] - ar * x[t][n][i] + a0

            if ci[t + 1][n][i] >= max_ci and t != 0:
                ci[t + 1][n][i] = max_ci
            elif ci[t + 1][n][i] <= -max_ci and t != 0:
                ci[t + 1][n][i] = -max_ci

            x[t + 1][n][i] = lab.sigmoid(ni[t + 1][n][i] + ci[t + 1][n][i])
    lab.number_to_image(x[t][pattern], t)
    process_bar.show_process()
Beispiel #4
0
                        
                        for s in range(100):
                                if t != 0:
                                        u_sum += abs(x[t][partten][s]-es*x[t-1][partten][s])
                        
                        for j in range(100):
                                wij_some += wij[i][j]*x[t][n][j]
                        ni[t+1][n][i] = kf*ni[t][n][i] + wij_some
                        ci[t+1][n][i] = kr*ci[t][n][i] - ar*(belt**(K*u_sum))*x[t][n][i] + a0
                        x[t+1][n][i] = lab.sigmoid(ni[t+1][n][i]+ci[t+1][n][i])   
        process_bar.show_process()  
        #lab.number_to_image(x[t][partten],t)
        plt.scatter(t,u_sum,s = 0.1, c = 'b')


plt.show()

"""
lab.number_to_image(x[0][0],1)
lab.number_to_image(x[0][1],2)
lab.number_to_image(x[0][2],3)
lab.number_to_image(x[0][3],4)
"""

"""
if we change from u_sum += abs(x[t][partten][s]-x[t-1][partten][s]) 
to  u_sum += abs(x[t][partten][s]-x[t-1][partten][s]/2)

it's obvious that we get a higher quality of control
"""