Skip to content

Commit

Permalink
Added a function to calculate timings and modified artificial matrix …
Browse files Browse the repository at this point in the history
…again for not having stack connectivies when you have the same sequence twice
  • Loading branch information
h-mayorquin committed Sep 6, 2017
1 parent 33e2d25 commit 0bfaf39
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 0 deletions.
23 changes: 23 additions & 0 deletions analysis_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,29 @@ def calculate_timings(manager, remove=0.010):
return timings


def calculate_recall_time_quantities(manager, T_recall, T_cue, n, sequences):

success = calculate_recall_success_sequences(manager, T_recall, T_cue, n, sequences)[0]
timings = calculate_timings(manager, remove=0.010)
patterns = [x[0] for x in timings]

# Check correct subsequence recalling
flag = subsequence(patterns, sequences[0])
n_min = min(len(sequences[0]), len(timings))

if flag:
time = [x[1] for x in timings[:n_min]]
total_sequence_time = sum(time)
mean = np.mean(time[1:-1])
std = np.std(time[1:-1])
else:
total_sequence_time = 0
mean = 0
std = 0

return total_sequence_time, mean, std, success


def calculate_compression_factor(manager, training_time, exclude_extrema=True, remove=0):
"""
Calculate compression factors for the timings
Expand Down
39 changes: 39 additions & 0 deletions connectivity_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,45 @@ def load_minicolumn_matrix(w, sequence_indexes, value=1, inhibition=-1, extensio
# Transform it to linear decay
sequence_decay = value * sequence_decay

for index, pattern_index in enumerate(sequence_indexes[:-1]):
# Determine the value to load
sequence_value = value - sequence_decay * index
# This is in case it decays bellow 0
if sequence_value <= 0:
sequence_value = 0

# First we set the the sequence connection
from_unit = pattern_index
to_unit = sequence_indexes[index + 1]

# If the unit has never been modified change the value to store
w[to_unit, from_unit] = sequence_value


# Then set the after-effects (extension)
if index < n_patterns - extension - 1:
aux = extension
else:
aux = n_patterns - index - 1

aux_decay_factor = sequence_value * decay_factor
for j in range(1, aux):
to_unit = sequence_indexes[index + 1 + j]

to_store = sequence_value - aux_decay_factor * j
# If this gets bellow 0
if to_store <= 0:
to_store = 0
w[to_unit, from_unit] = to_store

def load_minicolumn_matrix2(w, sequence_indexes, value=1, inhibition=-1, extension=1,
decay_factor=1.0, sequence_decay=1.0):

n_patterns = len(sequence_indexes)

# Transform it to linear decay
sequence_decay = value * sequence_decay

for index, pattern_index in enumerate(sequence_indexes[:-1]):
# Determine the value to load
sequence_value = value - sequence_decay * index
Expand Down
Empty file.
Empty file.
Empty file.

0 comments on commit 0bfaf39

Please sign in to comment.