Skip to content
Snippets Groups Projects
Commit 86ebd3a9 authored by Eloy Retamino's avatar Eloy Retamino Committed by Axel von Arnim
Browse files

Merged in NRRPLT-7679-direct-nest-extra-models (pull request #31)


[NRRPLT-7679] Added UGR VOR brain direct nest version

* [NRRPLT-7679] Added UGR VOR brain direct nest version

* [NRRPLT-7679] Added extended Braitenberg brain direct nest version

Approved-by: default avatarStefano Nardo <stefano.nardo@santannapisa.it>
Approved-by: default avatarAxel von Arnim <axel.vonarnim@fortiss.org>
parent 2e25bca9
No related tags found
No related merge requests found
# -*- coding: utf-8 -*-
"""
This file contains the setup of the neuronal network running the Husky experiment with neuronal image recognition
"""
# pragma: no cover
import nest
import logging
import random
logger = logging.getLogger(__name__)
def create_brain():
"""
Initializes NEST with the neuronal network that has to be simulated
"""
##
## Set up neurons
##
INPUT_PARAMS = {'a': 4.0,
'b': 0.0805,
'Delta_T': 2.0,
'tau_w': 144.0,
'V_peak': 0.0,
'C_m': 281.0, # ev. /1000
'E_L': -70.6,
'g_L': 281.0/9.3666667,
'E_ex': 0.0,
'E_in': -80.0,
'V_reset': -70.6,
'V_th': -50.4,
't_ref': 10.0,
'tau_syn_ex': 5.,
'tau_syn_in': 5.}
SENSORPARAMS = {'b': 0.0,
'tau_w': 10.0,
'V_peak': 0.0,
'C_m': 25.,
'E_L': -60.5,
'g_L': 25./10.,
'E_ex': 0.0,
'E_in': -75.0,
'V_reset': -60.5,
'V_th': -60.0,
't_ref': 10.0,
'tau_syn_ex': 2.5,
'tau_syn_ex': 7.5}
GO_ON_PARAMS = {'C_m': 25.,
'E_L': -60.5,
'g_L': 25./10.,
'E_ex': 0.0,
'E_in': -75.0,
'V_reset': -61.6,
'V_th': -60.51,
't_ref': 10.0,
'tau_syn_ex': 2.5,
'tau_syn_ex': 7.5}
INTERMEDIATE_PARAMS = {'a': 4.0,
'b': 0.0805,
'Delta_T': 2.0,
'tau_w': 144.0,
'V_peak': 0.0,
'C_m': 281.0, # ev. /1000
'V_reset': -70.6,
'g_L': 281.0/112.4,
'E_ex': 0.0,
'E_in': -80.0,
'V_reset': -70.6,
'V_th': -50.4,
't_ref': 10.0,
'tau_syn_ex': 5.,
'tau_syn_ex': 5.}
population = nest.Create('aeif_cond_alpha', 709)
nest.SetStatus(population[0:600], INPUT_PARAMS)
nest.SetStatus(population[600:605], SENSORPARAMS)
nest.SetStatus(population[605:606], GO_ON_PARAMS)
nest.SetStatus(population[606:608], SENSORPARAMS)
nest.SetStatus(population[608:708], INTERMEDIATE_PARAMS)
nest.SetStatus(population[708:709], GO_ON_PARAMS)
##
## Set up synapse types
##
SYNAPSE_PARAMS = {
"delay": 0.1,
}
# Synaptic weights
weight_red_to_actor = 15. # was 1.5e-4
weight_red_to_go_on = 1.0e6 # or -1.2e-3?
weight_green_blue_to_actor = 1.0e3
weight_go_on_to_right_actor = 1.4e-1 # was 1.4e-4
weight_eval_red = 25.
weight_eval_to_red_sensor = 8.75e-2 # was 1.0e-4, then 8.75e-5
weight_eval_to_bg_sensor = 5.0e3 # was 1.5, then 10.0, change it further
weight_red_to_blue_eval = 1.0e6 # was 5e-8
DELAY = 0.1
synapse_red_to_actor = {'model': 'static_synapse', 'weight': weight_red_to_actor, 'delay': DELAY}
synapse_red_to_go_on = {'model': 'static_synapse', 'weight': -weight_red_to_go_on,'delay': DELAY}
synapse_green_blue_to_actor = {'model': 'static_synapse', 'weight': weight_green_blue_to_actor,
'delay': DELAY}
synapse_go_on_to_right_actor ={'model': 'static_synapse', 'weight': weight_go_on_to_right_actor,
'delay': DELAY}
synapse_eval_red = {'model': 'static_synapse', 'weight': weight_eval_red, 'delay': DELAY}
synapse_eval_to_red_sensor = {'model': 'static_synapse', 'weight': weight_eval_to_red_sensor,
'delay': DELAY}
synapse_eval_to_bg_sensor = {'model': 'static_synapse', 'weight': weight_eval_to_bg_sensor,
'delay': DELAY}
synapse_red_to_blue_eval = {'model': 'static_synapse', 'weight': -weight_red_to_blue_eval,
'delay': DELAY}
##
## Set up projections
##
nest.Connect(population[602:603], population[607:608],
'all_to_all',
synapse_red_to_actor)
nest.Connect(population[603:604], population[606:607],
'all_to_all',
synapse_red_to_actor)
nest.Connect(population[600:602], population[605:606],
'all_to_all',
synapse_red_to_go_on)
nest.Connect(population[604:605], population[607:608],
'all_to_all',
synapse_green_blue_to_actor)
nest.Connect(population[605:606], population[607:608],
'all_to_all',
synapse_go_on_to_right_actor)
# connect the left portion of the detector neurons to the left evaluator and the right portion to the right one
pre = random.sample(range(300), 300)
for i in range(608,658):
for j in range(6):
nest.Connect([population[pre[j+(i-608)*6]]], [population[i]],
'one_to_one',
synapse_eval_red)
pre = random.sample(range(300,600), 300)
for i in range(658,708):
for j in range(6):
nest.Connect([population[pre[j+(i-658)*6]]], [population[i]],
'one_to_one',
synapse_eval_red)
nest.Connect(population[608:658], population[600:601],
'all_to_all',
synapse_eval_to_red_sensor)
nest.Connect(population[608:658], population[602:603],
'all_to_all',
synapse_eval_to_red_sensor)
nest.Connect(population[658:708], population[601:602],
'all_to_all',
synapse_eval_to_red_sensor)
nest.Connect(population[658:708], population[603:604],
'all_to_all',
synapse_eval_to_red_sensor)
nest.Connect(population[600:602], population[604:605],
'all_to_all',
synapse_red_to_blue_eval)
nest.Connect(population[708:709], population[604:605],
'one_to_one',
synapse_eval_to_bg_sensor) # connect the "blue green evaluator" to the blue green sensor
return population
circuit = create_brain()
sensors = circuit[0:605]
actors = circuit[605:608]
evaluators = circuit[608:709]
# -*- coding: utf-8 -*-
"""
This file contains the setup of the neuronal network running the iCub experiment in a VOR task
"""
# pragma: no cover
__author__ = 'Francisco Naveros, Jesus Garrido, Niceto Luque, Eduardo Ros'
### The following can be removed when PyNN 0.8 has been established or we have a more elegant
### solution
import nest
import numpy as np
import logging
import time
from pyNN.random import RandomDistribution, NumpyRNG
logger = logging.getLogger(__name__)
# Synapsis parameters
gc_pc_weights = 5.0
mf_vn_weights = 1.0
pc_vn_weights = 20.0 #NOTE: applied a factor of 1e06 wrt pynn version to this weight.
io_pc_weights = 0.0
mf_gc_weights = 0.6
go_gc_weights = -0.2
input_weights = 0.25
mf_go_weights = 0.6
# Network parameters
num_MF_neurons = 100
num_GC_neurons = 2000
num_GOC_neurons = 100
num_PC_neurons = 200
num_VN_neurons = 200
num_IO_neurons = 200
nest.SetKernelStatus({'resolution':0.5, 'min_delay':0.5, 'max_delay':100.0})
def create_brain():
"""
Initializes PyNN with the neuronal network that has to be simulated for the experiment
"""
s_start = time.time()
GR_PARAMS = {'C_m': 2.0,
'E_L': -70.0,
'g_L': 2.0/100., #'tau_minus': 100.0,
'E_ex': 0.0,
'E_in': -75.0,
'V_reset': -70.0,
'V_th': -40.0,
't_ref': 1.0,
'tau_syn_ex': 0.5,
'tau_syn_in': 2.0,
'V_m': -70.0}
GO_PARAMS = {'C_m': 2.0,
'E_L': -70.0,
'g_L': 2.0/100., #'tau_minus': 100.0,
'E_ex': 0.0,
'E_in': -75.0,
'V_reset': -70.0,
'V_th': -40.0,
't_ref': 1.0,
'tau_syn_ex': 0.5,
'tau_syn_in': 2.0,
'V_m': -70.0}
PC_PARAMS = {'C_m': 314.0,
'g_L': 12.0,
'E_L': -70.0,
'E_ex': 0.0,
'E_in': -75.0,
'e_cs': 0.0,
'V_reset': -70.0,
'V_th': -52.0,
't_ref': 1.0,
'tau_syn_ex': 0.85,
'tau_syn_in': 5.45,
'tau_syn_cs': 0.85,
'V_m': -70.0}
VN_PARAMS = {'C_m': 2.0,
'g_L': 0.2,
'E_L': -70.0,
'E_ex': 0.0,
'E_in': -80.0,
'e_ts': 0.0,
'V_reset': -70.5,
'V_th': -40.0,
't_ref': 1.0,
'tau_syn_ex': 0.5,
'tau_syn_in': 7.0,
'tau_syn_ts': 0.85,
'tau_cos': 10.0,
'exponent': 2.0,
'V_m': -70.5}
##THIS MODULE CAN BE DOWNLOADED FROM https://github.com/jgarridoalcazar/SpikingCerebellum/
#try:
# nest.Install('cerebellummodule')
#except nest.NESTError:
# pass
# Create MF population
MF_population = nest.Create('parrot_neuron', num_MF_neurons, params = {})
# Create GOC population
GOC_population = nest.Create('iaf_cond_alpha', num_GOC_neurons, params = GO_PARAMS)
print 'created MF and GOC populations: {s}'.format(s=time.time()-s_start)
# Create MF-GO connections
mf_go_connections = nest.Connect(MF_population, GOC_population, 'one_to_one', {"model": "static_synapse", "weight":mf_go_weights, "delay":1.0})
print 'created MF-GO connections: {s}'.format(s=time.time()-s_start)
# Create GrC population
GC_population = nest.Create('iaf_cond_alpha', num_GC_neurons, params = GR_PARAMS)
print 'created GrC populations: {s}'.format(s=time.time()-s_start)
# Random distribution for synapses delays and weights
delay_distr = {'distribution': 'uniform', 'low': 1.0, 'high': 10.0}
weight_distr_MF = {'distribution': 'uniform', 'low': mf_gc_weights*0.8, 'high': mf_gc_weights*1.2}
weight_distr_GO = {'distribution': 'uniform', 'low': go_gc_weights*1.2, 'high': go_gc_weights*0.8}
# Create MF-GC and GO-GC connections
float_num_MF_neurons = float (num_MF_neurons)
for i in range (num_MF_neurons):
GC_medium_index = int(round((i / float_num_MF_neurons) * num_GC_neurons))
GC_lower_index = GC_medium_index - 40
GC_upper_index = GC_medium_index + 60
if(GC_lower_index < 0):
GC_lower_index = 0
elif(GC_upper_index > num_GC_neurons):
GC_upper_index = num_GC_neurons
if(GC_lower_index < GC_medium_index):
GO_GC_con1 = nest.Connect(GOC_population[i: i+1],
GC_population[GC_lower_index: GC_medium_index],
'all_to_all', {"model": "static_synapse", "weight":weight_distr_GO, "delay":delay_distr})
MF_GC_con2 = nest.Connect(MF_population[i: i+1],
GC_population[GC_medium_index: GC_medium_index + 20],
'all_to_all', {"model": "static_synapse", "weight":weight_distr_MF, "delay":delay_distr})
if((GC_medium_index + 20) < GC_upper_index):
GO_GC_con3 = nest.Connect(GOC_population[i: i+1],
GC_population[GC_medium_index + 20: GC_upper_index],
'all_to_all', {"model": "static_synapse", "weight":weight_distr_GO, "delay":delay_distr})
print 'created MF-GC and GO-GC connections: {s}'.format(s=time.time()-s_start)
# Create PC population (THIS MODEL HAS BEEN DEFINED IN THE CEREBELLUMMODULE PACKAGE: https://github.com/jgarridoalcazar/SpikingCerebellum/)
PC_population = nest.Create('iaf_cond_exp_cs', num_PC_neurons, params = PC_PARAMS)
print 'created PC populations: {s}'.format(s=time.time()-s_start)
# Create VN population (THIS MODEL HAS BEEN DEFINED IN THE CEREBELLUMMODULE PACKAGE: https://github.com/jgarridoalcazar/SpikingCerebellum/)
VN_population = nest.Create('iaf_cond_exp_cos', num_VN_neurons, params = VN_PARAMS)
print 'created VN populations: {s}'.format(s=time.time()-s_start)
# Create IO population
IO_population = nest.Create('parrot_neuron', num_IO_neurons,params = {})
print 'created IO populations: {s}'.format(s=time.time()-s_start)
# Create MF-VN learning rule (THIS MODEL HAS BEEN DEFINED IN THE CEREBELLUMMODULE PACKAGE: https://github.com/jgarridoalcazar/SpikingCerebellum/)
# Create MF-VN connections
mf_vn_connections = nest.Connect(MF_population,
VN_population,
'all_to_all', #AMPA
{'model':'stdp_cos_synapse','weight':mf_vn_weights, 'receptor_type': 1,
'delay':1.0,
'exponent': 2.0,
'tau_cos': 10.0,
'A_plus': 0.0009,
'A_minus': 0.01,
'Wmin': 0.5,
'Wmax': 7.0})
print 'created MF-VN connections: {s}'.format(s=time.time()-s_start)
# Create PC-VN connections
pc_vn_connections = nest.Connect(PC_population,
VN_population,
'one_to_one', #GABA
{"model": "static_synapse", "weight":pc_vn_weights, 'receptor_type': 2 ,"delay":1.0})
# This second synapse with "receptor_type=TEACHING_SIGNAL" propagates the learning signals that drive the plasticity mechanisms in MF-VN synapses
pc_vn_connections_2 = nest.Connect(PC_population,
VN_population,
'one_to_one', #TEACHING_SIGNAL
{"model": "static_synapse", "weight":0.0, 'receptor_type': 3 ,"delay":1.0})
print 'created PC-VN connections: {s}'.format(s=time.time()-s_start)
# Create MF-VN learning rule (THIS MODEL HAS BEEN DEFINED IN THE CEREBELLUMMODULE PACKAGE: https://github.com/jgarridoalcazar/SpikingCerebellum/)
# Create GC-PC connections
gc_pc_connections = nest.Connect(GC_population,
PC_population,
'all_to_all',#AMPA
{'weight':gc_pc_weights, 'model': 'stdp_sin_synapse', 'receptor_type': 1,
'delay':1.0,
'exponent': 10,
'peak': 100.0,
'A_plus': 0.014,
'A_minus': 0.08,
'Wmin': 0.000,
'Wmax': 10.0})
print 'created GC-PC connections: {s}'.format(s=time.time()-s_start)
# Create IO-PC connections. This synapse with "receptor_type=COMPLEX_SPIKE" propagates the learning signals that drive the plasticity mechanisms in GC-PC synapses
io_pc_connections = nest.Connect(IO_population,
PC_population,
'one_to_one', #COMPLEX_SPIKE
{"model": "static_synapse", "weight":io_pc_weights, 'receptor_type': 3 ,"delay":1.0})
print 'created IO-PC connections: {s}'.format(s=time.time()-s_start)
# Group all neural layers
population = MF_population + GOC_population + GC_population + PC_population + VN_population + IO_population
# Set Vm to resting potential
# sim.initialize(PC_population, V_m=PC_population.get('E_L'))
# sim.initialize(VN_population, V_m=VN_population.get('E_L'))
print 'num of cells: {s}'.format(s = len(population))
return population
circuit = create_brain()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment