Auryn simulator  v0.8.1-206-gb56e451
Plastic Spiking Neural Network Simulator
Macros | Functions
sim_isp_big.cpp File Reference

This simulation illustrates inhibitory synaptic plasticity as modeled in Vogels et al. (2011) in a larger 200k cell network. More...

#include "auryn.h"
Include dependency graph for sim_isp_big.cpp:

Macros

#define NE   160000
 Number of excitatory neurons. More...
 
#define NI   40000
 Number of inhibitory neurons. More...
 

Functions

int main (int ac, char *av[])
 

Detailed Description

This simulation illustrates inhibitory synaptic plasticity as modeled in Vogels et al. (2011) in a larger 200k cell network.

This simulation illustrates inhibitory synapitc plasticity as modeled in our paper: Vogels, T.P., Sprekeler, H., Zenke, F., Clopath, C., and Gerstner, W. (2011). Inhibitory Plasticity Balances Excitation and Inhibition in Sensory Pathways and Memory Networks. Science 334, 1569–1573.

Note that this is a parallel implementation of this network which requires a larger axonal delay than in the original paper. In this example the delay is 0.8ms which corresponds to Auryn's MINDELAY.

Macro Definition Documentation

◆ NE

#define NE   160000

Number of excitatory neurons.

◆ NI

#define NI   40000

Number of inhibitory neurons.

Function Documentation

◆ main()

int main ( int  ac,
char *  av[] 
)
47 {
48  double w = 0.0035;
49  double w_ext = w ;
50  double gamma = 10. ;
51  double wmax = 1000*gamma*w;
52 
53  double sparseness = 0.02;
54 
55  double eta = 1e-5 ;
56  double kappa = 3. ;
57  double tau_stdp = 20e-3 ;
58  bool stdp_active = true;
59  bool poisson_stim = false;
60  bool record_voltage = false;
61  double winh = -1;
62  double wei = 1;
63  double chi = 2.;
64  double lambda = 1.;
65  double bg_current = 2.0e-2;//1.01e-2;
66 
67  double sparseness_afferents = 0.05;
68 
69  bool quiet = false;
70  bool save = false;
71  double simtime = 1000. ;
72  NeuronID record_neuron = 30;
73  // handle command line options
74 
75  string simname = "isp_big";
76  string infilename = "";
77  string patfilename = "";
78  string outputfile = "";
79  string dir = ".";
80  string stimfile = "";
81  string strbuf ;
82  string msg;
83 
84  int errcode = 0;
85 
86  try {
87 
88  po::options_description desc("Allowed options");
89  desc.add_options()
90  ("help", "produce help message")
91  ("quiet", "quiet mode")
92  ("save", "save state at the end for loading")
93  ("voltage", "activate voltage monitor")
94  ("load", po::value<string>(), "input weight matrix")
95  ("pat", po::value<string>(), "pattern file")
96  ("dir", po::value<string>(), "output dir")
97  ("stimfile", po::value<string>(), "stimulus file")
98  ("eta", po::value<double>(), "learning rate")
99  ("kappa", po::value<double>(), "target rate")
100  ("simtime", po::value<double>(), "simulation time")
101  ("active", po::value<bool>(), "toggle learning")
102  ("poisson", po::value<bool>(), "toggle poisson stimulus")
103  ("winh", po::value<double>(), "inhibitory weight multiplier")
104  ("wei", po::value<double>(), "ei weight multiplier")
105  ("chi", po::value<double>(), "chi recall parameter")
106  ("lambda", po::value<double>(), "lambda storage parameter")
107  ("sparseness", po::value<double>(), "sparseness of connections")
108  ;
109 
110  po::variables_map vm;
111  po::store(po::parse_command_line(ac, av, desc), vm);
112  po::notify(vm);
113 
114  if (vm.count("help")) {
115  std::cout << desc << "\n";
116  return 1;
117  }
118 
119  if (vm.count("quiet")) {
120  quiet = true;
121  }
122 
123  if (vm.count("save")) {
124  save = true;
125  }
126 
127  if (vm.count("voltage")) {
128  record_voltage = true;
129  }
130 
131  if (vm.count("load")) {
132  infilename = vm["load"].as<string>();
133  }
134 
135  if (vm.count("pat")) {
136  patfilename = vm["pat"].as<string>();
137  }
138 
139  if (vm.count("dir")) {
140  dir = vm["dir"].as<string>();
141  }
142 
143  if (vm.count("stimfile")) {
144  stimfile = vm["stimfile"].as<string>();
145  }
146 
147  if (vm.count("eta")) {
148  eta = vm["eta"].as<double>();
149  }
150 
151  if (vm.count("kappa")) {
152  kappa = vm["kappa"].as<double>();
153  }
154 
155  if (vm.count("simtime")) {
156  simtime = vm["simtime"].as<double>();
157  }
158 
159  if (vm.count("active")) {
160  stdp_active = vm["active"].as<bool>();
161  }
162 
163  if (vm.count("poisson")) {
164  poisson_stim = vm["poisson"].as<bool>();
165  }
166 
167 
168  if (vm.count("winh")) {
169  winh = vm["winh"].as<double>();
170  }
171 
172  if (vm.count("wei")) {
173  wei = vm["wei"].as<double>();
174  }
175 
176  if (vm.count("chi")) {
177  chi = vm["chi"].as<double>();
178  }
179 
180  if (vm.count("lambda")) {
181  lambda = vm["lambda"].as<double>();
182  }
183 
184  if (vm.count("sparseness")) {
185  sparseness = vm["sparseness"].as<double>();
186  }
187 
188  }
189  catch(std::exception& e) {
190  std::cerr << "error: " << e.what() << "\n";
191  return 1;
192  }
193  catch(...) {
194  std::cerr << "Exception of unknown type!\n";
195  }
196 
197  // BEGIN Global definitions
198  auryn_init( ac, av );
199  sys->set_simulation_name(simname);
200  // END Global definitions
201 
202 
203  logger->msg("Setting up neuron groups ...",PROGRESS,true);
204  TIFGroup * neurons_e = new TIFGroup(NE);
205  TIFGroup * neurons_i = new TIFGroup(NI);
206  neurons_e->random_mem(-60e-3,5e-3);
207  // neurons_e->random_nmda(2,1);
208  neurons_i->random_mem(-60e-3,5e-3);
209 
210 
211  logger->msg("Setting up I connections ...",PROGRESS,true);
212  SparseConnection * con_ei = new SparseConnection(neurons_e,neurons_i,wei*w,sparseness,GLUT,"EI connection");
213  // con_ei->random_data(wei*w,wei*0.3*w);
214  SparseConnection * con_ii = new SparseConnection(neurons_i,neurons_i,gamma*w,sparseness,GABA,"II connection");
215  // con_ii->random_data(gamma*w,gamma*0.3*w);
216 
217  IdentityConnection * con_exte;
218  if ( !stimfile.empty() && poisson_stim==true) {
219  logger->msg("Setting up StimulusGroup ...",PROGRESS,true);
220  StimulusGroup * stimgroup = new StimulusGroup(NE,stimfile,"",SEQUENTIAL,100);
221  con_exte = new IdentityConnection(stimgroup,neurons_e,0.2,GLUT,"external input");
222  stimgroup->set_mean_on_period(0.5);
223  stimgroup->set_mean_off_period(20.);
224 
225  logger->msg("Enabling stimulus monitors ...",PROGRESS,true);
226  strbuf = outputfile;
227  strbuf += ".stimact";
228  PatternMonitor * patmon = new PatternMonitor( stimgroup, strbuf.c_str(),patfilename.c_str());
229  }
230 
231  logger->msg("Setting up E connections ...",PROGRESS,true);
232 
233  SparseConnection * con_ee
234  = new SparseConnection(neurons_e,neurons_e,w,sparseness,GLUT,"EE connection");
235 
236  SparseConnection * con_ie
237  = new SparseConnection(neurons_i,neurons_e,gamma*w,sparseness,GABA,"IE connection");
238 
239  // SymmetricSTDPConnection * con_ie
240  // = new SymmetricSTDPConnection(
241  // neurons_i,neurons_e,
242  // gamma*w,sparseness,
243  // gamma*eta,kappa,tau_stdp,wmax,
244  // GABA,"IE connection");
245 
246  if (!infilename.empty()) {
247  logger->msg("Loading previous network state...",PROGRESS,true);
248  sys->load_network_state(infilename);
249  }
250 
251  if (winh>=0)
252  con_ie->set_all(winh);
253 
254  if (!patfilename.empty()) {
255  logger->msg("Loading patterns ...",PROGRESS,true);
256  con_ee->load_patterns(patfilename,lambda*w);
257 
258  logger->msg("Enabling pattern monitors ...",PROGRESS,true);
259  strbuf = outputfile;
260  strbuf += ".patact";
261  PatternMonitor * patmon = new PatternMonitor(neurons_e, strbuf.c_str(),patfilename.c_str());
262  }
263 
264  logger->msg("Setting up monitors ...",PROGRESS,true);
265  strbuf = outputfile;
266  strbuf += ".e.ras";
267  SpikeMonitor * smon_e = new SpikeMonitor( neurons_e, strbuf );
268 
269  strbuf = outputfile;
270  strbuf += ".i.ras";
271  SpikeMonitor * smon_i = new SpikeMonitor( neurons_i, strbuf );
272 
273 
274  if ( record_voltage ) {
275  strbuf = outputfile;
276  strbuf += ".mem";
277  VoltageMonitor * vmon = new VoltageMonitor( neurons_e, record_neuron, strbuf.c_str() );
278 
279  strbuf = outputfile;
280  strbuf += ".ampa";
281  StateMonitor * amon = new StateMonitor( neurons_e, record_neuron, "g_ampa", strbuf.c_str() );
282 
283  strbuf = outputfile;
284  strbuf += ".gaba";
285  StateMonitor * gmon = new StateMonitor( neurons_e, record_neuron, "g_gaba", strbuf.c_str() );
286  }
287 
288  RateChecker * chk = new RateChecker( neurons_e , 0.001 , 1000. , 100e-3);
289 
290  for ( int j = 0; j < (NE) ; j++ ) {
291  neurons_e->set_bg_current(j,bg_current);
292  }
293 
294  for ( int j = 0; j < (NI) ; j++ ) {
295  neurons_i->set_bg_current(j,bg_current);
296  }
297 
298  // We don't have an efficient way of setting input
299  // currents from a file. So we do int manually here.
300  if (!stimfile.empty() && poisson_stim==false) {
301  logger->msg("Loading pattern ..." ,PROGRESS,true);
302  char buffer[256];
303  std::ifstream fin(stimfile.c_str());
304  if (!fin) {
305  std::cout << "There was a problem opening file "
306  << stimfile
307  << " for reading."
308  << std::endl;
309  logger->msg("There was a problem opening file." ,ERROR,true);
310  return 1;
311  }
312 
313  while ( fin.getline(buffer,256) ) {
314  std::stringstream iss( buffer );
315  NeuronID id;
316  iss >> id;
317 
318  if (poisson_stim==false) {
319  neurons_e->set_bg_current(id,chi*bg_current);
320  }
321 
322  }
323  fin.close();
324 
325  logger->msg("Running ..." ,PROGRESS,true);
326  sys->run(2);
327 
328  logger->msg("Resetting ..." ,PROGRESS,true);
329  for ( int j = 0; j < (NE) ; j++ ) {
330  neurons_e->set_bg_current(j,bg_current);
331  }
332 
333  }
334 
335  logger->msg("Simulating ..." ,PROGRESS,true);
336  // con_ie->stdp_active = stdp_active;
337 
338  if (!sys->run(simtime,true))
339  errcode = 1;
340 
341  if (save) {
342  logger->msg("Saving network state ..." ,PROGRESS,true);
343  sys->save_network_state(outputfile);
344  }
345 
346  if (errcode)
347  auryn_abort(errcode);
348 
349  logger->msg("Freeing ..." ,PROGRESS,true);
350  auryn_free();
351 
352  return errcode;
353 }
void auryn_free()
Cleanly shuts down Auryn simulation environment.
Definition: auryn_global.cpp:107
Standard Glutamatergic (excitatory) transmission.
Definition: auryn_definitions.h:139
void set_mean_on_period(AurynFloat period)
Set mean on period.
Definition: StimulusGroup.cpp:156
#define NI
Number of inhibitory neurons.
Definition: sim_isp_big.cpp:41
void random_mem(AurynState mean=-60e-3, AurynState sigma=5e-3)
Definition: NeuronGroup.cpp:81
void load_network_state(std::string basename)
Loads network state from a netstate file.
Definition: System.cpp:812
A Checker class that tracks population firing rate as a moving average and breaks a run if it goes ou...
Definition: RateChecker.h:59
The base class to create sparse random connections.
Definition: SparseConnection.h:66
Definition: auryn_definitions.h:148
Monitor class to record population firing rates.
Definition: PatternMonitor.h:47
Logger * logger
Global pointer to instance of Logger which needs to be initialized in every simulation main program...
Definition: auryn_global.cpp:36
void set_simulation_name(std::string name)
Sets the simulation name.
Definition: System.cpp:654
The standard Monitor object to record spikes from a SpikingGroup and write them to a text file...
Definition: SpikeMonitor.h:52
virtual void set_all(AurynWeight weight)
Sets all weights of existing connections to the given value.
Definition: SparseConnection.cpp:335
void auryn_abort(int errcode)
Terminates Auryn simulation abnormally.
Definition: auryn_global.cpp:113
System * sys
Global pointer to instance of System which needs to be initialized in every simulation main program...
Definition: auryn_global.cpp:37
Definition: Logger.h:41
Provides a poisson stimulus at random intervals in one or more predefined subsets of the group that a...
Definition: StimulusGroup.h:50
Records the membrane potential from one unit from the source neuron group to a file.
Definition: VoltageMonitor.h:48
#define NE
Number of excitatory neurons.
Definition: sim_isp_big.cpp:40
Conductance based LIF neuron model with absolute refractoriness as used in Vogels and Abbott 2005...
Definition: TIFGroup.h:38
void auryn_init(int ac, char *av[], string dir, string simulation_name, string logfile_prefix, LogMessageType filelog_level, LogMessageType consolelog_level)
Initalizes MPI and the Auryn simulation environment.
Definition: auryn_global.cpp:84
void set_bg_current(NeuronID i, AurynFloat current)
Controls the constant current input (per default set so zero) to neuron i.
Definition: TIFGroup.cpp:121
Standard Gabaergic (inhibitory) transmission.
Definition: auryn_definitions.h:140
void msg(std::string text, LogMessageType type=NOTIFICATION, bool global=false, int line=-1, std::string srcfile="")
Definition: Logger.cpp:74
void load_patterns(string filename, AurynWeight strength, int nb_max_patterns=10000, bool overwrite=false, bool chainmode=false)
Reads first n patterns from a .pat file and adds them as Hebbian assemblies onto an existing weight m...
Definition: SparseConnection.cpp:1057
Definition: Logger.h:41
void save_network_state(std::string basename)
Saves network state to a netstate file.
Definition: System.cpp:694
void set_mean_off_period(AurynFloat period)
Set mean quiet interval between consecutive stimuli.
Definition: StimulusGroup.cpp:150
Records from an arbitray state vector of one unit from the source SpikingGroup to a file...
Definition: StateMonitor.h:40
unsigned int NeuronID
NeuronID is an unsigned integeger type used to index neurons in Auryn.
Definition: auryn_definitions.h:151
Provides a unity matrix like connectivity.
Definition: IdentityConnection.h:47
Here is the call graph for this function: