User Tools

Site Tools


neurali:nemo_appunti_c

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
neurali:nemo_appunti_c [2015/07/21 19:40] profproneurali:nemo_appunti_c [2020/06/08 22:20] (current) – external edit 127.0.0.1
Line 1: Line 1:
 +=====Appunti su Nemo======
 +[[neurali:nemo]]
 +
 +Esempio da capire e commentare (tratto dai sorgenti di NeMo)
 +
 +<code c++>
 +/* Simple network with 1000 neurons with all-to-all connections with random
 + * weights.
 +
 + * Author: Andreas K. Fidjeland <andreas.fidjeland@imperial.ac.uk>
 + * Date: April 2010
 + */
 +
 +#include <vector>
 +
 +#include <string>
 +#include <iostream>
 +#include <fstream>
 +#include <boost/program_options.hpp>
 +#include <boost/scoped_ptr.hpp>
 +#include <examples/common.hpp>
 +#include <nemo/Timer.hpp>
 +#include <boost/random.hpp>
 +#include <nemo.hpp>
 +
 +typedef boost::mt19937 rng_t;
 +typedef boost::variate_generator<rng_t&, boost::uniform_real<double> > urng_t;
 +typedef boost::variate_generator<rng_t&, boost::uniform_int<> > uirng_t;
 +
 +/*....................*/
 +nemo::Network*
 +construct(unsigned ncount, unsigned scount, unsigned dmax, bool stdp)
 +{
 + rng_t rng;
 + /* Neuron parameters and weights are partially randomised */
 + urng_t randomParameter(rng, boost::uniform_real<double>(0, 1));
 + uirng_t randomTarget(rng, boost::uniform_int<>(0, ncount-1));
 + uirng_t randomDelay(rng, boost::uniform_int<>(1, dmax));
 +
 + nemo::Network* net = new nemo::Network();
 +
 + for(unsigned nidx=0; nidx < ncount; ++nidx) {
 + if(nidx < (ncount * 4) / 5) { // excitatory
 + addExcitatoryNeuron(net, nidx, randomParameter);
 + for(unsigned s = 0; s < scount; ++s) {
 + net->addSynapse(nidx, randomTarget(), randomDelay(), 0.5f * float(randomParameter()), false);
 + }
 + } else { // inhibitory
 + addInhibitoryNeuron(net, nidx, randomParameter);
 + for(unsigned s = 0; s < scount; ++s) {
 + net->addSynapse(nidx, randomTarget(), 1U, float(-randomParameter()), 0);
 + }
 + }
 + }
 + return net;
 +}
 +</code>
 +
 +
 +quali include ?
 +
 +  nemo/util.h
 +  nemo/config.h
 +  nemo.hpp
 +  boost/program_options.hpp
 +  boost/random.hpp
 +  boost/scoped_ptr.hpp
 +  
 +
 +classi (in minuscolo!) boost da studiare
 +
 +  boost:program_options.options_desciption
 +  boost:program_options.variables_map
 +  boost:program_options.store
 +  boost:program_options.parse_command_line
 +  boost:program_options.notify
 +
 +funzioni boost da studiare
 +
 +  boost::uniform_real<·>(·)
 +  boost::variate_generator<·,·>
 +  boost::bernoulli_distribution...
 +  
 +Funzioni di esempio (utilizzabili?)
 +
 +  addExcitatoryNeuron
 +  addInhibitoryNeuron
 +  simulate
 +  vmap
 +  processOptions
 +  random::nemo::Network * construct ()
 +  
 +NOTA: I tempi **Delay** di una sinapsi potrebbero essere un altro modo per tenere conto delle **distanze** fisiche tra neuroni.
 +
 +Funzioni da approfondire
 +
 +  simulazione.resetTimer()
 +  simulazione.step() che restituisce un vector contenente i neuroni che si sono attivati
 +  simulazione.applyStdp()
 +  simulazione.elapsedWallclock()
 +  simulazione.getMembranePotential()
 +  
 +  configurazione.setStdpFunction()
 +  configurazione.setWriteOnlySynapses()
 +  configurazione.enableLogging()
 +  configurazione.setSpuBackend()
 +  
  
neurali/nemo_appunti_c.txt · Last modified: 2020/06/08 22:20 by 127.0.0.1