Skip to content

Commit

Permalink
bugfix pattern_tools: size of vector with changed neurons was not cor…
Browse files Browse the repository at this point in the history
…rect
  • Loading branch information
MarcoLehmann committed Mar 28, 2018
1 parent f1758a9 commit b0a8a53
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
6 changes: 3 additions & 3 deletions neurodynex/hopfield_network/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def run_demo():
"""
# Demo2: more neurons, more patterns, more noise
run_hf_demo(pattern_size=6, nr_random_patterns=5, initially_flipped_pixels=11, nr_iterations=5)
# run_hf_demo(pattern_size=6, nr_random_patterns=5, initially_flipped_pixels=11, nr_iterations=5)

# Demo3: more parameters
# run_hf_demo(pattern_size=4, nr_random_patterns=5,
Expand Down Expand Up @@ -180,5 +180,5 @@ def upd_random(state_s0, weights):


if __name__ == '__main__':
# run_demo()
run_user_function_demo()
run_demo()
# run_user_function_demo()
2 changes: 1 addition & 1 deletion neurodynex/hopfield_network/pattern_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def get_noisy_copy(template, noise_level):
n = np.prod(template.shape)
nr_mutations = int(round(n * noise_level))
idx_reassignment = np.random.choice(n, nr_mutations, replace=False)
rand_values = np.random.binomial(1, 0.5, n)
rand_values = np.random.binomial(1, 0.5, nr_mutations)
rand_values = rand_values * 2 - 1 # map {0,1} to {-1, +1}
linear_template[idx_reassignment] = rand_values
return linear_template.reshape(template.shape)
Expand Down
9 changes: 6 additions & 3 deletions neurodynex/tools/spike_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@

def get_spike_time(voltage_monitor, spike_threshold):
"""
Detects the spike times in the voltage. The spike time is the value in voltage_monitor.t for
which voltage_monitor.v[idx] is above threshold AND voltage_monitor.v[idx-1] is below threshold
(crossing from below).
Detects the spike times in the voltage. Here, the spike time is DEFINED as the value in
voltage_monitor.t for which voltage_monitor.v[idx] is above threshold AND
voltage_monitor.v[idx-1] is below threshold (crossing from below).
Note: currently only the spike times of the first column in voltage_monitor are detected. Matrix-like
monitors are not supported.
Args:
Expand All @@ -57,6 +57,9 @@ def get_spike_time(voltage_monitor, spike_threshold):
def get_spike_stats(voltage_monitor, spike_threshold):
"""
Detects spike times and computes ISI, mean ISI and firing frequency.
Here, the spike time is DEFINED as the value in
voltage_monitor.t for which voltage_monitor.v[idx] is above threshold AND
voltage_monitor.v[idx-1] is below threshold (crossing from below).
Note: meanISI and firing frequency are set to numpy.nan if less than two spikes are detected
Note: currently only the spike times of the first column in voltage_monitor are detected. Matrix-like
monitors are not supported.
Expand Down

0 comments on commit b0a8a53

Please sign in to comment.