Skip to content

Commit

Permalink
Update the notebooks, make k.inner=False the default
Browse files Browse the repository at this point in the history
  • Loading branch information
h-mayorquin committed Mar 30, 2017
1 parent 3a59cb8 commit 3dba22d
Show file tree
Hide file tree
Showing 9 changed files with 842 additions and 207 deletions.
Empty file added __init__.py
Empty file.
Empty file added benchmarking/__init__.py
Empty file.
Empty file.
Empty file.
31 changes: 22 additions & 9 deletions network.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def update_continuous(self, dt=1.0, sigma=None):
class BCPNNFast:
def __init__(self, hypercolumns, minicolumns, beta=None, w=None, G=1.0, tau_m=0.050, g_w=1, g_w_ampa=1.0, g_beta=1,
tau_z_pre=0.150, tau_z_post=0.005, tau_z_pre_ampa=0.005, tau_z_post_ampa=0.005, tau_p=5.0, tau_k=0.010,
tau_a=2.70, g_a=97.0, g_I=10.0, p=1.0, k=0.0, sigma=1.0, epsilon=1e-20, k_inner=True, prng=np.random):
tau_a=2.70, g_a=97.0, g_I=10.0, p=1.0, k=0.0, sigma=1.0, epsilon=1e-20, k_inner=False, prng=np.random):
# Initial values are taken from the paper on memory by Marklund and Lansner also from Phil's paper

# Random number generator
Expand Down Expand Up @@ -714,17 +714,30 @@ def create_overload_chain(self, number_of_sequences, half_width, units_to_overlo

sequence = []

for i in range(half_width):
sequence.append(number)
number += 1
sequence += units_to_overload
# The first half
i = 0
while i < half_width:
if number in units_to_overload:
number += 1

else:
sequence.append(number)
number += 1
i += 1

for i in range(half_width):
sequence.append(number)
number += 1
# The overload units in the middle
sequence += units_to_overload

# The second half
i = 0
while i < half_width:
if number in units_to_overload:
number += 1
else:
sequence.append(number)
number += 1
i += 1

chain.append(sequence)

return chain

1 change: 0 additions & 1 deletion notebooks/2017-03-24(Speed of patterns study).ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@
"\n",
"for epochs in epochs_range:\n",
" # Protocol\n",
" training_time = 0.1\n",
" inter_sequence_interval = 1.0\n",
" inter_pulse_interval = 0.0\n",
"\n",
Expand Down
439 changes: 319 additions & 120 deletions notebooks/2017-03-28(Unit load study).ipynb

Large diffs are not rendered by default.

501 changes: 501 additions & 0 deletions notebooks/2017-03-30(Unit Load II).ipynb

Large diffs are not rendered by default.

77 changes: 0 additions & 77 deletions play.py
Original file line number Diff line number Diff line change
@@ -1,77 +0,0 @@
from __future__ import print_function

import pprint

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

from network import BCPNN, NetworkManager, BCPNNFast, Protocol
from plotting_functions import plot_state_variables_vs_time, plot_network_activity, plot_network_activity_angle
from plotting_functions import plot_adaptation_dynamics, plot_weight_matrix
from analysis_functions import calculate_compression_factor, calculate_recall_success, calculate_timings
from plotting_functions import plot_winning_pattern, plot_sequence, plot_network_activity_angle

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

# Patterns parameters
hypercolumns = 4
minicolumns = 30

# Manager properties
dt = 0.001
T_recall = 3.0
values_to_save = ['o']

compression_list = []


# Protocol
training_time = 0.1
inter_sequence_interval = 1.0
inter_pulse_interval = 0.0
epochs = 3

# Build the network
nn = BCPNNFast(hypercolumns, minicolumns)
nn.k_inner = False

# Build the manager
manager = NetworkManager(nn=nn, dt=dt, values_to_save=values_to_save)

# Build the protocol for
protocol = Protocol()

number_of_sequences = 3
half_width = 2
units_to_overload = [10]
chain = []

protocol = Protocol()
chain = protocol.create_overload_chain(number_of_sequences, half_width, units_to_overload)
protocol.cross_protocol(chain, training_time, inter_sequence_interval, epochs)
# Train
manager.run_network_protocol(protocol, verbose=False, values_to_save_epoch=None, reset=True, empty_history=True)

# Recall
if True:
manager.run_network_recall(T_recall=T_recall, T_cue=0.1, I_cue=0, reset=True, empty_history=True)
manager.run_network_recall(T_recall=T_recall, T_cue=0.1, I_cue=5, reset=True, empty_history=False)
manager.run_network_recall(T_recall=T_recall, T_cue=0.1, I_cue=11, reset=True, empty_history=False)
manager.run_network_recall(T_recall=T_recall, T_cue=0.1, I_cue=15, reset=True, empty_history=False)

# Timings
timings = calculate_timings(manager, remove=0.010)
print(timings)

plot_winning_pattern(manager, remove=0.010)
plt.show()

if True:
n = 5
for sequence in chain:
success = calculate_recall_success(manager, T_recall=T_recall, I_cue=sequence[0], T_cue=0.1, n=n,
patterns_indexes=sequence)
print(success)

0 comments on commit 3dba22d

Please sign in to comment.