<jupyter_start><jupyter_text>Temporal association in assymetric neural networksThis is an attempt to reproduce this paper.https://journals.aps.org/prl/abstract/10.1103/PhysRevLett.57.2861<jupyter_code>import pprint
import subprocess
import sys 
sys.path.append('../')

import numpy as np
import matplotlib.pyplot as plt
import matplotlib
import matplotlib.gridspec as gridspec
from mpl_toolkits.axes_grid1 import make_axes_locatable
import seaborn as sns

%matplotlib inline
plt.rcParams['figure.figsize'] = (12.9, 12)

np.set_printoptions(suppress=True, precision=2)

sns.set(font_scale=3.5)<jupyter_output><empty_output><jupyter_text>Let's first create some random pattenrs with 1 and -1<jupyter_code>n_network = 500  # The size of the network
n_patterns = 10
n_sequence = 10
l = 2.5

patterns_to_store = np.random.choice([-1, 1], size=(n_patterns, n_network), replace=True)<jupyter_output><empty_output><jupyter_text>Let's build the connectivity matrices<jupyter_code>J1 = np.zeros((n_network, n_network))

for pattern in patterns_to_store:
    J1 += np.outer(pattern, pattern)
    
J1 /= n_network
J2 = np.zeros((n_network, n_network))
for index in range(n_patterns - 1):
    J2 += np.outer(patterns_to_store[index + 1], patterns_to_store[index])
    
J2 *= (l / n_network)<jupyter_output><empty_output><jupyter_text>Now let's make the system evolve<jupyter_code>T = 50
tau = 8
S_initial = np.array([patterns_to_store[0] for i in range(tau)])
S_aux = np.zeros((T, n_network))
S = np.vstack((S_initial, S_aux))

for t in range(tau, T + tau - 1):
    h1 = J1 @ S[t, :]
    S_avg = (1 / tau) * S[(t - tau):t, :].sum(axis=0)
    h2 = J2 @ S_avg
    S[t + 1, :] = np.sign(h1 + h2)<jupyter_output><empty_output><jupyter_text>Now we need to calculate the overlaps to see the evolution of the system.<jupyter_code>m = np.zeros(((tau + T), n_patterns))

for t in range(tau + T):
    for index, pattern in enumerate(patterns_to_store):
        m[t, index] = (1 / n_network) * (S[t, :] @ pattern)
cmap = sns.color_palette("Reds_r", n_colors=n_patterns)

for index, overlap in enumerate(m.T):
    plt.plot(overlap, color=cmap[index], lw=5)
plt.matshow(S)
S[-4, ...]<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13351623228166437, 'fraction_numerical': 0.026977594878829447, 'mean_word_length': 5.111731843575419, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '496044', 'license': 'MIT', 'n_tokens_mistral': 899, 'n_tokens_neox': 848, 'n_words': 195, 'path': 'notebooks/2018-03-22(Sompolinsky Draft).ipynb', 'repo_name': 'h-mayorquin/sequence_papers_reproduction', 'size': '2187'}