diff --git a/config_rewiring_ex10.yaml b/config_rewiring_ex10.yaml index 1110b98..cebced9 100644 --- a/config_rewiring_ex10.yaml +++ b/config_rewiring_ex10.yaml @@ -1,23 +1,23 @@ # Configuration file for sim_rewiring_ex10.py --- master_seed: 10 -simulation_time: "n/a" # Is set in script -sampling_interval_weights: 10.0 +simulation_time: 3600.0 +sampling_interval_weights: 0.3 input_parameters: num_inputs: 320 - pattern_delay: "n/a" # Is set in script - pattern_duration: "n/a" # Is set in script - num_assemblies: 8 + pattern_delay: 0.2 + pattern_duration: 0.3 + num_assemblies: 7 assembly_size: 40 - rate: 35.0 + rate: 30.0 rate_bg: 1.0 connection_parameters: n_syn_start: 20 n_syn_max: 20 w_max: 8.0 - w_ini_min: 4.0 + w_ini_min: 8.0 w_ini_max: 8.0 theta_ini: -0.5 theta_min: -2.0 @@ -29,13 +29,15 @@ connection_parameters: A: 0.0 B: -3.2 stdp_th: -67.0 - stdp_active: False + stdp_active: True scale_w: 0.55 scale_prior: 1.0 - gaussian_prior_active: False + gaussian_prior_active: True gaussian_prior_mean: 8.0 - gaussian_prior_std: 2.0 - scale_gaussian_prior: 0.004 + gaussian_prior_thr: 7.0 + gaussian_prior_std_high: 1.0 + gaussian_prior_std_low: 32.0 + scale_gaussian_prior: 1.0 scale_likelihood: 1.5 tau_pre: 20e-3 tau_post: 20e-3 diff --git a/config_rewiring_ex11.yaml b/config_rewiring_ex11.yaml index c9b1b4f..06b7e37 100644 --- a/config_rewiring_ex11.yaml +++ b/config_rewiring_ex11.yaml @@ -2,16 +2,18 @@ --- master_seed: 10 simulation_time: "n/a" # Is set in script -sampling_interval_weights: 10.0 +sampling_interval_weights: 0.3 input_parameters: num_inputs: 320 - pattern_delay: "n/a" # Is set in script - pattern_duration: "n/a" # Is set in script + pattern_delay: 0.2 + pattern_duration: 0.3 num_assemblies: 8 assembly_size: 40 rate: 35.0 rate_bg: 1.0 + num_patterns_per_assembly: 250 + num_test_patterns_per_assembly: 2 connection_parameters: n_syn_start: 20 @@ -32,10 +34,11 @@ connection_parameters: stdp_active: True scale_w: 0.55 scale_prior: 1.0 - gaussian_prior_active: False + gaussian_prior_active: True gaussian_prior_mean: 8.0 - gaussian_prior_std: 2.0 - scale_gaussian_prior: 0.004 + gaussian_prior_thr: 7.0 + gaussian_prior_std_high: 1.0 + gaussian_prior_std_low: 32.0 scale_likelihood: 1.5 tau_pre: 20e-3 tau_post: 20e-3 diff --git a/config_rewiring_ex12.yaml b/config_rewiring_ex12.yaml deleted file mode 100644 index 0126b4d..0000000 --- a/config_rewiring_ex12.yaml +++ /dev/null @@ -1,67 +0,0 @@ -# Configuration file for sim_rewiring_ex12.py ---- -master_seed: 10 -simulation_time: "n/a" # Is set in script -sampling_interval_weights: 0.3 - -input_parameters: - num_inputs: 320 - pattern_delay: 0.2 - pattern_duration: 0.3 - num_assemblies: 8 - assembly_size: 40 - rate: 35.0 - rate_bg: 1.0 - num_patterns_per_assembly: 250 - num_test_patterns_per_assembly: 2 - -connection_parameters: - n_syn_start: 20 - n_syn_max: 20 - w_max: 8.0 - w_ini_min: 4.0 - w_ini_max: 8.0 - theta_ini: -0.5 - theta_min: -2.0 - T: 0.3 - eta: 0.002 - lambd: 10.0 - gamma: 0.2 - grad_sigmoid_clip: 8.0 - A: 0.0 - B: -3.2 - stdp_th: -67.0 - stdp_active: True - scale_w: 0.55 - scale_prior: 1.0 - gaussian_prior_active: True - gaussian_prior_mean: 8.0 - gaussian_prior_thr: 7.0 - gaussian_prior_std_high: 1.0 - gaussian_prior_std_low: 32.0 - scale_likelihood: 1.5 - tau_pre: 20e-3 - tau_post: 20e-3 - -neuron_parameters: - num_branches: 12 - branch_parameters: - v_thr: -55.0 - v_rest: -70.0 - r_mem: 40e6 - c_mem: 250e-12 - tau_syn: 2e-3 - tau_sod: 4e-3 - v_pla: -30.0 - a_sod_max: 5.0 - scale_pla: 40e-3 - plateau_duration_min: 20e-3 - plateau_duration_max: 300e-3 - soma_parameters: - v_thr: -55.0 - v_rest: -70.0 - r_l: 2.0 - r_mem: 40e6 - c_mem: 250e-12 - tau_syn: 2e-3 - refractory_period: 5e-3 diff --git a/config_rewiring_ex9.yaml b/config_rewiring_ex9.yaml index a8a242b..5db5a8e 100644 --- a/config_rewiring_ex9.yaml +++ b/config_rewiring_ex9.yaml @@ -1,23 +1,23 @@ # Configuration file for sim_rewiring_ex9.py --- master_seed: 10 -simulation_time: 3600.0 -sampling_interval_weights: 0.3 +simulation_time: "n/a" # Is set in script +sampling_interval_weights: 10.0 input_parameters: num_inputs: 320 - pattern_delay: 0.2 - pattern_duration: 0.3 - num_assemblies: 7 + pattern_delay: "n/a" # Is set in script + pattern_duration: "n/a" # Is set in script + num_assemblies: 8 assembly_size: 40 - rate: 30.0 + rate: 35.0 rate_bg: 1.0 connection_parameters: n_syn_start: 20 n_syn_max: 20 w_max: 8.0 - w_ini_min: 8.0 + w_ini_min: 4.0 w_ini_max: 8.0 theta_ini: -0.5 theta_min: -2.0 @@ -32,12 +32,10 @@ connection_parameters: stdp_active: True scale_w: 0.55 scale_prior: 1.0 - gaussian_prior_active: True + gaussian_prior_active: False gaussian_prior_mean: 8.0 - gaussian_prior_thr: 7.0 - gaussian_prior_std_high: 1.0 - gaussian_prior_std_low: 32.0 - scale_gaussian_prior: 1.0 + gaussian_prior_std: 2.0 + scale_gaussian_prior: 0.004 scale_likelihood: 1.5 tau_pre: 20e-3 tau_post: 20e-3 diff --git a/sensitivity_analysis_ex2.py b/sensitivity_analysis_ex2.py new file mode 100644 index 0000000..06f8558 --- /dev/null +++ b/sensitivity_analysis_ex2.py @@ -0,0 +1,109 @@ +#!/usr/bin/env python +"""Sensitivity analysis for rewiring_ex2.""" + +import os +import time +from functools import partial + +import utils as utils +from spaghetti import spaghetti_global as spaghetti +from spaghetti.mc_lif_group import McLifGroup +from spaghetti.poisson_pattern_group import PoissonPatternGroup +from spaghetti.rewiring_connection import RewiringConnection +from spaghetti.spike_monitor import SpikeMonitor +from spaghetti.voltage_monitor import VoltageMonitor +from spaghetti.weight_matrix_monitor import WeightMatrixMonitor + + +def main(args, param, change): + trial = args[0] + config = args[1] + input_params = config["input_parameters"] + connection_params = config["connection_parameters"] + neuron_params = config["neuron_parameters"] + + # Directory for simulation results and log files. + output_directory = os.path.join( + os.path.sep, "calc", os.getenv("USER"), "data", "dendritic_rewiring", + "rewiring_ex2", "sensitivity_analysis", param, change, time.strftime("%y%m%d_%H%M%S"), str(trial), + "data") + + # Initialize the simulation environment. + spaghetti.spaghetti_init(directory=output_directory) + + # Write config file to the output directory. + utils.write_configuration(os.path.join(output_directory, "..", "config_rewiring_ex2.yaml"), config) + + # Set the random seed. + spaghetti.kernel.set_master_seed(config["master_seed"]) + + # Create input neurons. + inp = PoissonPatternGroup(input_params["num_inputs"], input_params["rate"], input_params["rate_bg"], + params=input_params) + + # Create the neuron. + neuron = McLifGroup(1, neuron_params["num_branches"], neuron_params) + + # Connect input to neuron. + conn = RewiringConnection(inp, neuron, neuron.branch.syn_current, connection_params) + + # Create some monitors which will record the simulation data. + WeightMatrixMonitor(conn, spaghetti.kernel.fn("weights", "dat"), + interval=config["sampling_interval_weights"]) + SpikeMonitor(neuron, spaghetti.kernel.fn("output", "ras")) + sm_inp = SpikeMonitor(inp, spaghetti.kernel.fn("input", "ras")) + vm_nrn = VoltageMonitor(neuron.soma, 0, spaghetti.kernel.fn("soma", "mem")) + vm_br = [] + for i in range(neuron_params["num_branches"]): + vm_br.append(VoltageMonitor(neuron.branch, (i, 0), spaghetti.kernel.fn("branch", "mem", i))) + + # Now simulate the model. + simulation_time = config["simulation_time"] + spaghetti.kernel.run_chunk(20.0, 0, simulation_time) + + sm_inp.active = False + vm_nrn.active = False + for vm in vm_br: + vm.active = False + spaghetti.kernel.run_chunk(simulation_time - 40, 0, simulation_time) + + sm_inp.active = True + vm_nrn.active = True + for vm in vm_br: + vm.active = True + spaghetti.kernel.run_chunk(20.0, 0, simulation_time) + + +if __name__ == '__main__': + import copy + from scoop import futures + + # Load the configuration file. + config = utils.load_configuration("experiments/config_rewiring_ex2.yaml") + + # Change a specific parameter. + param = "plateau_duration_max" + delta_param = +0.1 # +-10 % + + # params = config["connection_parameters"] + params = config["neuron_parameters"]["branch_parameters"] + + value = params[param] + if value >= 0: + params[param] += delta_param * value + else: + params[param] += -delta_param * value + + if delta_param >= 0: + change = "+" + str(abs(delta_param) * 100) + else: + change = "-" + str(abs(delta_param) * 100) + + configs = [] + num_trials = 25 + for trial in range(num_trials): + config["master_seed"] = 10 * (trial + 1) + configs.append(copy.deepcopy(config)) + + partial_main = partial(main, param=param, change=change) + r = list(futures.map(partial_main, [[trial, config] for trial, config in enumerate(configs)])) diff --git a/sim_rewiring_ex10.py b/sim_rewiring_ex10.py index fb03caf..421420d 100644 --- a/sim_rewiring_ex10.py +++ b/sim_rewiring_ex10.py @@ -1,7 +1,17 @@ #!/usr/bin/env python -"""Analyze influence of pattern duration and delay duration on clustering (without STDP).""" +"""This script is meant to analyze the effect of the temperature T on the change in the synaptic weights. + +We start with 20 synapses/per branch for each of the 8 assemblies (8 branches have connections to 20 different +input neurons; the remaining 4 branches are not connected). We set the weights to the maximum and simulate for +t seconds, where 7 assemblies are active during simulation and 1 assembly only spikes with a background rate +of 1Hz. We are interessted in the weight change of that one branch that has connections to the assembly that +is silent during simulation. +""" import os +import time + +import numpy as np from core import core_global as core from core.spike_monitor import SpikeMonitor @@ -21,8 +31,8 @@ def main(args): neuron_params = config["neuron_parameters"] # Directory for simulation results and log files. - name = str(1e3 * input_params["pattern_delay"]) + "d" + str(1e3 * input_params["pattern_duration"]) + "p" - output_directory = os.path.join("results", "rewiring_ex10", name, str(trial), "data") + output_directory = os.path.join("results", "rewiring_ex10", "T" + str(connection_params["T"]), + time.strftime("%y%m%d_%H%M%S"), str(trial), "data") # Initialize the simulation environment. core.init(directory=output_directory) @@ -43,6 +53,22 @@ def main(args): # Connect input to neuron. conn = RewiringConnection(inp, neuron, neuron.branch.syn_current, connection_params) + # Set the weights. + size = (neuron_params["num_branches"], input_params["num_inputs"]) + theta_ini = connection_params["theta_ini"] + theta = np.full(size, theta_ini, np.float32) + + assembly_neurons_idc = [i * input_params["assembly_size"] + np.arange(input_params["assembly_size"]) + for i in range(input_params["num_assemblies"]+1)] + + for idc, row in zip(assembly_neurons_idc, theta): + row[core.kernel.rng.choice(idc, connection_params["n_syn_start"], replace=False)] = \ + core.kernel.rng.uniform(low=connection_params["w_ini_min"], + high=connection_params["w_ini_max"], + size=connection_params["n_syn_start"]) + + conn.set_weights(theta) + # Create some monitors which will record the simulation data. WeightMatrixMonitor(conn, core.kernel.fn("weights", "dat"), interval=config["sampling_interval_weights"]) @@ -71,32 +97,16 @@ def main(args): if __name__ == '__main__': - import itertools import copy from scoop import futures # Load the configuration file. config = utils.load_configuration("config_rewiring_ex10.yaml") - # Combinations of delays and pattern durations. - use_const_active_time = True - default_active_time = 600 # seconds - d = list(range(0, 250, 50)) - p = list(range(50, 350, 50)) - - def simtime(d, p): - return default_active_time + default_active_time / p * d - configs = [] num_trials = 25 - combinations = itertools.product(d, p) - for pattern_delay, pattern_duration in combinations: - for trial in range(num_trials): - config["master_seed"] = 10 * (trial + 1) - if use_const_active_time: - config["simulation_time"] = simtime(pattern_delay, pattern_duration) - config["input_parameters"]["pattern_delay"] = 1e-3 * pattern_delay - config["input_parameters"]["pattern_duration"] = 1e-3 * pattern_duration - configs.append(copy.deepcopy(config)) - - r = list(futures.map(main, [[trial % 25, config] for trial, config in enumerate(configs)])) + for trial in range(num_trials): + config["master_seed"] = 10 * (trial + 1) + configs.append(copy.deepcopy(config)) + + r = list(futures.map(main, [[trial, config] for trial, config in enumerate(configs)])) diff --git a/sim_rewiring_ex11.py b/sim_rewiring_ex11.py index 11cdf4b..390b9d0 100644 --- a/sim_rewiring_ex11.py +++ b/sim_rewiring_ex11.py @@ -1,7 +1,9 @@ #!/usr/bin/env python -"""Analyze influence of pattern duration and delay duration on clustering (with STDP).""" +"""Shows that catastrophic forgetting can be avoided. We use an additional Gaussian prior on the weights in +this experiment (as opposed to rewiring_ex3, which shows the same without Gaussian prior).""" import os +import time from core import core_global as core from core.spike_monitor import SpikeMonitor @@ -19,10 +21,16 @@ def main(args): input_params = config["input_parameters"] connection_params = config["connection_parameters"] neuron_params = config["neuron_parameters"] + simulation_time_per_pattern = (input_params["pattern_delay"] + input_params["pattern_duration"]) + config["simulation_time"] = ( + simulation_time_per_pattern * input_params["num_assemblies"] * ( + input_params["num_patterns_per_assembly"] + + input_params["num_assemblies"] * + input_params["num_test_patterns_per_assembly"])) # Directory for simulation results and log files. - name = str(1e3 * input_params["pattern_delay"]) + "d" + str(1e3 * input_params["pattern_duration"]) + "p" - output_directory = os.path.join("results", "rewiring_ex11", name, str(trial), "data") + output_directory = os.path.join("results", "rewiring_ex11", time.strftime("%y%m%d_%H%M%S"), str(trial), + "data") # Initialize the simulation environment. core.init(directory=output_directory) @@ -44,59 +52,53 @@ def main(args): conn = RewiringConnection(inp, neuron, neuron.branch.syn_current, connection_params) # Create some monitors which will record the simulation data. - WeightMatrixMonitor(conn, core.kernel.fn("weights", "dat"), - interval=config["sampling_interval_weights"]) - SpikeMonitor(neuron, core.kernel.fn("output", "ras")) sm_inp = SpikeMonitor(inp, core.kernel.fn("input", "ras")) + sm_nrn = SpikeMonitor(neuron, core.kernel.fn("output", "ras")) vm_nrn = VoltageMonitor(neuron.soma, 0, core.kernel.fn("soma", "mem")) vm_br = [] for i in range(neuron_params["num_branches"]): vm_br.append(VoltageMonitor(neuron.branch, (i, 0), core.kernel.fn("branch", "mem", i))) + WeightMatrixMonitor(conn, core.kernel.fn("weights", "dat"), + interval=config["sampling_interval_weights"]) # Now simulate the model. simulation_time = config["simulation_time"] - core.kernel.run_chunk(20.0, 0, simulation_time) - sm_inp.active = False - vm_nrn.active = False - for vm in vm_br: - vm.active = False - core.kernel.run_chunk(simulation_time - 40, 0, simulation_time) - - sm_inp.active = True - vm_nrn.active = True - for vm in vm_br: - vm.active = True - core.kernel.run_chunk(20.0, 0, simulation_time) + for assembly in range(input_params["num_assemblies"]): + conn.learn = True + sm_inp.active = False + vm_nrn.active = False + for vm in vm_br: + vm.active = False + inp.set_assemblies(assembly) + core.kernel.run_chunk(input_params["num_patterns_per_assembly"] * + simulation_time_per_pattern, 0, + simulation_time) + for assembly in range(input_params["num_assemblies"]): + conn.learn = False + sm_inp.active = True + sm_nrn.active = True + vm_nrn.active = True + for vm in vm_br: + vm.active = True + inp.set_assemblies(assembly) + core.kernel.run_chunk( + input_params["num_test_patterns_per_assembly"] * + simulation_time_per_pattern, 0, simulation_time) if __name__ == '__main__': - import itertools import copy from scoop import futures # Load the configuration file. config = utils.load_configuration("config_rewiring_ex11.yaml") - # Combinations of delays and pattern durations. - use_const_active_time = True - default_active_time = 600 # seconds - d = list(range(0, 250, 50)) - p = list(range(50, 350, 50)) - - def simtime(d, p): - return default_active_time + default_active_time / p * d - configs = [] num_trials = 25 - combinations = itertools.product(d, p) - for pattern_delay, pattern_duration in combinations: - for trial in range(num_trials): - config["master_seed"] = 10 * (trial + 1) - if use_const_active_time: - config["simulation_time"] = simtime(pattern_delay, pattern_duration) - config["input_parameters"]["pattern_delay"] = 1e-3 * pattern_delay - config["input_parameters"]["pattern_duration"] = 1e-3 * pattern_duration - configs.append(copy.deepcopy(config)) - - r = list(futures.map(main, [[trial % 25, config] for trial, config in enumerate(configs)])) + for trial in range(num_trials): + config["master_seed"] = 10 * (trial + 1) + config["sampling_interval_weights"] = 0.3 + configs.append(copy.deepcopy(config)) + + r = list(futures.map(main, [[trial, config] for trial, config in enumerate(configs)])) diff --git a/sim_rewiring_ex12.py b/sim_rewiring_ex12.py deleted file mode 100644 index 8912121..0000000 --- a/sim_rewiring_ex12.py +++ /dev/null @@ -1,104 +0,0 @@ -#!/usr/bin/env python -"""Shows that catastrophic forgetting can be avoided. We use an additional Gaussian prior on the weights in -this experiment (as opposed to rewiring_ex3, which shows the same without Gaussian prior).""" - -import os -import time - -from core import core_global as core -from core.spike_monitor import SpikeMonitor -from core.voltage_monitor import VoltageMonitor -from core.weight_matrix_monitor import WeightMatrixMonitor -from layers.rewiring_connection import RewiringConnection -from models.mc_lif_group import McLifGroup -from models.poisson_pattern_group import PoissonPatternGroup -from utils import utils as utils - - -def main(args): - trial = args[0] - config = args[1] - input_params = config["input_parameters"] - connection_params = config["connection_parameters"] - neuron_params = config["neuron_parameters"] - simulation_time_per_pattern = (input_params["pattern_delay"] + input_params["pattern_duration"]) - config["simulation_time"] = ( - simulation_time_per_pattern * input_params["num_assemblies"] * ( - input_params["num_patterns_per_assembly"] + - input_params["num_assemblies"] * - input_params["num_test_patterns_per_assembly"])) - - # Directory for simulation results and log files. - output_directory = os.path.join("results", "rewiring_ex12", time.strftime("%y%m%d_%H%M%S"), str(trial), - "data") - - # Initialize the simulation environment. - core.init(directory=output_directory) - - # Write config file to the output directory. - utils.write_configuration(os.path.join(output_directory, "..", "config_rewiring_ex12.yaml"), config) - - # Set the random seed. - core.kernel.set_master_seed(config["master_seed"]) - - # Create input neurons. - inp = PoissonPatternGroup(input_params["num_inputs"], input_params["rate"], input_params["rate_bg"], - params=input_params) - - # Create the neuron. - neuron = McLifGroup(1, neuron_params["num_branches"], neuron_params) - - # Connect input to neuron. - conn = RewiringConnection(inp, neuron, neuron.branch.syn_current, connection_params) - - # Create some monitors which will record the simulation data. - sm_inp = SpikeMonitor(inp, core.kernel.fn("input", "ras")) - sm_nrn = SpikeMonitor(neuron, core.kernel.fn("output", "ras")) - vm_nrn = VoltageMonitor(neuron.soma, 0, core.kernel.fn("soma", "mem")) - vm_br = [] - for i in range(neuron_params["num_branches"]): - vm_br.append(VoltageMonitor(neuron.branch, (i, 0), core.kernel.fn("branch", "mem", i))) - WeightMatrixMonitor(conn, core.kernel.fn("weights", "dat"), - interval=config["sampling_interval_weights"]) - - # Now simulate the model. - simulation_time = config["simulation_time"] - - for assembly in range(input_params["num_assemblies"]): - conn.learn = True - sm_inp.active = False - vm_nrn.active = False - for vm in vm_br: - vm.active = False - inp.set_assemblies(assembly) - core.kernel.run_chunk(input_params["num_patterns_per_assembly"] * - simulation_time_per_pattern, 0, - simulation_time) - for assembly in range(input_params["num_assemblies"]): - conn.learn = False - sm_inp.active = True - sm_nrn.active = True - vm_nrn.active = True - for vm in vm_br: - vm.active = True - inp.set_assemblies(assembly) - core.kernel.run_chunk( - input_params["num_test_patterns_per_assembly"] * - simulation_time_per_pattern, 0, simulation_time) - - -if __name__ == '__main__': - import copy - from scoop import futures - - # Load the configuration file. - config = utils.load_configuration("config_rewiring_ex12.yaml") - - configs = [] - num_trials = 25 - for trial in range(num_trials): - config["master_seed"] = 10 * (trial + 1) - config["sampling_interval_weights"] = 0.3 - configs.append(copy.deepcopy(config)) - - r = list(futures.map(main, [[trial, config] for trial, config in enumerate(configs)])) diff --git a/sim_rewiring_ex9.py b/sim_rewiring_ex9.py index 4f9002c..d265ded 100644 --- a/sim_rewiring_ex9.py +++ b/sim_rewiring_ex9.py @@ -1,17 +1,7 @@ #!/usr/bin/env python -"""This script is meant to analyze the effect of the temperature T on the change in the synaptic weights. - -We start with 20 synapses/per branch for each of the 8 assemblies (8 branches have connections to 20 different -input neurons; the remaining 4 branches are not connected). We set the weights to the maximum and simulate for -t seconds, where 7 assemblies are active during simulation and 1 assembly only spikes with a background rate -of 1Hz. We are interessted in the weight change of that one branch that has connections to the assembly that -is silent during simulation. -""" +"""Analyze influence of pattern duration and delay duration on clustering (with STDP).""" import os -import time - -import numpy as np from core import core_global as core from core.spike_monitor import SpikeMonitor @@ -31,8 +21,8 @@ def main(args): neuron_params = config["neuron_parameters"] # Directory for simulation results and log files. - output_directory = os.path.join("results", "rewiring_ex9", "T" + str(connection_params["T"]), - time.strftime("%y%m%d_%H%M%S"), str(trial), "data") + name = str(1e3 * input_params["pattern_delay"]) + "d" + str(1e3 * input_params["pattern_duration"]) + "p" + output_directory = os.path.join("results", "rewiring_ex9", name, str(trial), "data") # Initialize the simulation environment. core.init(directory=output_directory) @@ -53,22 +43,6 @@ def main(args): # Connect input to neuron. conn = RewiringConnection(inp, neuron, neuron.branch.syn_current, connection_params) - # Set the weights. - size = (neuron_params["num_branches"], input_params["num_inputs"]) - theta_ini = connection_params["theta_ini"] - theta = np.full(size, theta_ini, np.float32) - - assembly_neurons_idc = [i * input_params["assembly_size"] + np.arange(input_params["assembly_size"]) - for i in range(input_params["num_assemblies"]+1)] - - for idc, row in zip(assembly_neurons_idc, theta): - row[core.kernel.rng.choice(idc, connection_params["n_syn_start"], replace=False)] = \ - core.kernel.rng.uniform(low=connection_params["w_ini_min"], - high=connection_params["w_ini_max"], - size=connection_params["n_syn_start"]) - - conn.set_weights(theta) - # Create some monitors which will record the simulation data. WeightMatrixMonitor(conn, core.kernel.fn("weights", "dat"), interval=config["sampling_interval_weights"]) @@ -97,16 +71,32 @@ def main(args): if __name__ == '__main__': + import itertools import copy from scoop import futures # Load the configuration file. config = utils.load_configuration("config_rewiring_ex9.yaml") + # Combinations of delays and pattern durations. + use_const_active_time = True + default_active_time = 600 # seconds + d = list(range(0, 250, 50)) + p = list(range(50, 350, 50)) + + def simtime(d, p): + return default_active_time + default_active_time / p * d + configs = [] num_trials = 25 - for trial in range(num_trials): - config["master_seed"] = 10 * (trial + 1) - configs.append(copy.deepcopy(config)) - - r = list(futures.map(main, [[trial, config] for trial, config in enumerate(configs)])) + combinations = itertools.product(d, p) + for pattern_delay, pattern_duration in combinations: + for trial in range(num_trials): + config["master_seed"] = 10 * (trial + 1) + if use_const_active_time: + config["simulation_time"] = simtime(pattern_delay, pattern_duration) + config["input_parameters"]["pattern_delay"] = 1e-3 * pattern_delay + config["input_parameters"]["pattern_duration"] = 1e-3 * pattern_duration + configs.append(copy.deepcopy(config)) + + r = list(futures.map(main, [[trial % 25, config] for trial, config in enumerate(configs)]))