nemo (version 0.7.1)
index
/usr/local/lib/python2.6/dist-packages/nemo/__init__.py

The NeMo spiking neural network simulator
=========================================
 
NeMo is a fast spiking neural network simulator which can run on CUDA-enabled
GPUs. The ``nemo`` module provides an object-oriented interface to the C++
class library. The interface is based around three classes: Network,
Configuration, and Simulation.
 
Basic usage is as follows:
 
1. create a configuration;
2. create and populate a network by adding individual neurons and synapses; and
3. create a simulation from the configuration and network object, and run the
   simulation providing stimulus and reading outputs as appropriate
 
More details can be found in the documentation for each of these classes.
 
The following example shows how a small network of 1000 neurons is created and
simulated for one second::
    
    import nemo
    import random
 
    net = nemo.Network()
    iz = net.add_neuron_type('Izhikevich')
 
    # Excitatory neurons
    for nidx in range(800):
        r = random.random()**2
        c = -65.0+15*r
        d = 8.0 - 6.0*r
        net.add_neuron(iz, nidx, 0.02, 0.2, c, d, 5.0, 0.2*c, c);
        targets = range(1000)
        weights = [0.5*random.random() for tgt in targets]
        net.add_synapse(nidx, targets, 1, weights, False);
 
    # Inhibitory neurons
    for n in range(200):
        nidx = 800 + n
        r = random.random()
        a = 0.02+0.08*r
        b = 0.25-0.05*r
        c = -65.0
        net.add_neuron(iz, nidx, a, b, c, 2.0, 2.0, b*c, c)
        targets = range(1000)
        weights = [-random.random() for tgt in targets]
        net.add_synapse(nidx, targets, 1, weights, False);
 
    conf = nemo.Configuration()
    sim = nemo.Simulation(net, conf)
    for t in range(1000):
        fired = sim.step()
        print t, ":", fired
 
There is also a higher-level interface using the PyNN common simulator
interface.  PyNN is a large separate project which is documented in full
elsewhere.

 
Package Contents
       

 
Classes
       
Boost.Python.instance(__builtin__.object)
_nemo.Configuration
_nemo.Network
_nemo.Simulation

 
class Configuration(Boost.Python.instance)
    Global configuration
 
 
Method resolution order:
Configuration
Boost.Python.instance
__builtin__.object

Methods defined here:
__init__(...)
__init__( (object)arg1) -> None :
 
    C++ signature :
        void __init__(_object*)
__reduce__ = (...)
backend_description(...)
backend_description( (Configuration)arg1) -> str :
    
    
    Description of the currently selected simulation backend
    
    Returns Textual description of the currently selected backend
    
    The backend can be changed using setCudaBackend or setCpuBackend
 
    C++ signature :
        char const* backend_description(nemo::Configuration {lvalue})
set_cpu_backend(...)
set_cpu_backend( (Configuration)arg1) -> None :
    
    
    specify that the CPU backend should be used
 
    C++ signature :
        void set_cpu_backend(nemo::Configuration {lvalue})
set_cuda_backend(...)
set_cuda_backend( (Configuration)arg1, (int)arg2) -> None :
    
    
    specify that the CUDA backend should be used
    
    Inputs:
    deviceNumber
    
    Specify that the CUDA backend should be used and optionally specify a
    desired device. If the (default) device value of -1 is used the backend
    will choose the best available device. If the cuda backend (and the chosen
    device) cannot be used for whatever reason, an exception is raised. The
    device numbering is the numbering used internally by nemo (see
    cudaDeviceCount and cudaDeviceDescription). This device numbering may
    differ from the one provided by the CUDA driver directly, since NeMo
    ignores any devices it cannot use.
 
    C++ signature :
        void set_cuda_backend(nemo::Configuration {lvalue},int)
set_stdp_function(...)
set_stdp_function( (Configuration)arg1, (std_vector_float)arg2, (std_vector_float)arg3, (float)arg4, (float)arg5) -> None :
    
    
    enable STDP and set the global STDP function
    
    Inputs:
    prefire -- STDP function values for spikes arrival times before the postsynaptic firing, starting closest to the postsynaptic firing
    postfire -- STDP function values for spikes arrival times after the postsynaptic firing, starting closest to the postsynaptic firing
    minWeight -- Lowest (negative) weight beyond which inhibitory synapses are not potentiated
    maxWeight -- Highest (positive) weight beyond which excitatory synapses are not potentiated
    
    The STDP function is specified by providing the values sampled at integer
    cycles within the STDP window.
 
    C++ signature :
        void set_stdp_function(nemo::Configuration {lvalue},std::vector<float, std::allocator<float> >,std::vector<float, std::allocator<float> >,float,float)

Data and other attributes defined here:
__instance_size__ = 24

Data descriptors inherited from Boost.Python.instance:
__dict__
__weakref__

Data and other attributes inherited from Boost.Python.instance:
__new__ = <built-in method __new__ of Boost.Python.class object>
T.__new__(S, ...) -> a new object with type S, a subtype of T

 
class Network(Boost.Python.instance)
    Network is constructed by adding individual neurons and synapses to the
network. Neurons are given indices (from 0) which should be unique for each
neuron. When adding synapses the source or target neurons need not
necessarily exist yet, but should be defined before the network is
finalised.
 
 
Method resolution order:
Network
Boost.Python.instance
__builtin__.object

Methods defined here:
__init__(...)
__init__( (object)arg1) -> None :
 
    C++ signature :
        void __init__(_object*)
__reduce__ = (...)
add_neuron(...)
object add_neuron(tuple args, dict kwds) :
    
    
    add one or more neurons to the network
    
    Inputs:
    type -- Neuron type
    idx -- Neuron index
    parameters... -- all neuron parameters
    state... -- all state variables
    
    The meaning of the parameters and state variables varies depending on the
    neuron typeThis function may be called either in a scalar or vector form.
    In the scalar form all inputs are scalars. In the vector form, the neuron
    index argument plus any number of the other arguments are lists of the same
    length. In this second form scalar inputs are replicated the appropriate
    number of times
 
    C++ signature :
        object add_neuron(tuple args, dict kwds)
add_neuron_type(...)
add_neuron_type( (Network)arg1, (str)arg2) -> int :
    
    
    register a new neuron type with the network
    
    Inputs:
    name -- canonical name of the neuron type. The neuron type data is loaded from a plugin configuration file of the same name.
    
    Returns index of the the neuron type, to be used when adding neurons
    
    This function must be called before neurons of the specified type can be
    added to the network.
 
    C++ signature :
        unsigned int add_neuron_type(nemo::Network {lvalue},std::string)
add_synapse(...)
add_synapse( (Network)arg1, (object)arg2, (object)arg3, (object)arg4, (object)arg5, (object)arg6) -> object :
    
    
    add a single synapse to the network
    
    Inputs:
    source -- Index of source neuron
    target -- Index of target neuron
    delay -- Synapse conductance delay in milliseconds
    weight -- Synapse weights
    plastic -- Boolean specifying whether or not this synapse is plastic
    
    Returns Unique synapse ID
    
    The input arguments can be any combination of lists of equal length and
    scalars. If the input arguments contain a mix of scalars and lists the
    scalar arguments are replicated the required number of times.
 
    C++ signature :
        _object* add_synapse(nemo::Network {lvalue},_object*,_object*,_object*,_object*,_object*)
get_neuron_parameter(...)
get_neuron_parameter( (Network)arg1, (object)arg2, (int)arg3) -> object :
    
    
    get neuron parameter
    
    Inputs:
    idx -- neuron index
    varno -- variable index
    
    Returns value of the neuron parameter
    
    The neuron parameters do not change during simulation. For the Izhikevich
    model: 0=a, 1=b, 2=c, 3=d. The neuron index may be either scalar or a list.
    The output has the same length as the neuron input
 
    C++ signature :
        _object* get_neuron_parameter(nemo::Network {lvalue},_object*,unsigned int)
get_neuron_state(...)
get_neuron_state( (Network)arg1, (object)arg2, (int)arg3) -> object :
    
    
    get neuron state variable
    
    Inputs:
    idx -- neuron index
    varno -- variable index
    
    Returns value of the relevant variable
    
    For the Izhikevich model: 0=u, 1=v. The neuron index may be either scalar
    or a list. The output has the same length as the neuron input
 
    C++ signature :
        _object* get_neuron_state(nemo::Network {lvalue},_object*,unsigned int)
get_synapse_delay(...)
get_synapse_delay( (Network)arg1, (object)arg2) -> object :
    
    
    return the conduction delay for the specified synapse
    
    Inputs:
    synapse -- synapse id (as returned by addSynapse)
    
    Returns conduction delay of the specified synapse
    
    The input synapse indices may be either a scalar or a list. The return
    value has the same form
 
    C++ signature :
        _object* get_synapse_delay(nemo::Network,_object*)
get_synapse_plastic(...)
get_synapse_plastic( (Network)arg1, (object)arg2) -> object :
    
    
    return the boolean plasticity status for the specified synapse
    
    Inputs:
    synapse -- synapse id (as returned by addSynapse)
    
    Returns plasticity status of the specified synapse
    
    The input synapse indices may be either a scalar or a list. The return
    value has the same form
 
    C++ signature :
        _object* get_synapse_plastic(nemo::Network,_object*)
get_synapse_source(...)
get_synapse_source( (Network)arg1, (int)arg2) -> int :
 
    C++ signature :
        unsigned int get_synapse_source(nemo::Network {lvalue},unsigned long)
 
get_synapse_source( (Network)arg1, (object)arg2) -> object :
    
    
    return the source neuron of the specified synapse
    
    Inputs:
    synapse -- synapse id (as returned by addSynapse)
    
    Returns source neuron index
    
    The input synapse indices may be either a scalar or a list. The return
    value has the same form
 
    C++ signature :
        _object* get_synapse_source(nemo::Network,_object*)
get_synapse_target(...)
get_synapse_target( (Network)arg1, (object)arg2) -> object :
    
    
    return the target of the specified synapse
    
    Inputs:
    synapse -- synapse id (as returned by addSynapse)
    
    Returns target neuron index
    
    The input synapse indices may be either a scalar or a list. The return
    value has the same form
 
    C++ signature :
        _object* get_synapse_target(nemo::Network,_object*)
get_synapse_weight(...)
get_synapse_weight( (Network)arg1, (object)arg2) -> object :
    
    
    return the weight for the specified synapse
    
    Inputs:
    synapse -- synapse id (as returned by addSynapse)
    
    Returns weight of the specified synapse
    
    The input synapse indices may be either a scalar or a list. The return
    value has the same form
 
    C++ signature :
        _object* get_synapse_weight(nemo::Network,_object*)
get_synapses_from(...)
get_synapses_from( (Network)arg1, (int)arg2) -> std_vector_uint64 :
    
    
    return the synapse ids for all synapses with the given source neuron
    
    Inputs:
    source -- source neuron index
    
    Returns synapse ids
    
    The input synapse indices may be either a scalar or a list. The return
    value has the same form
 
    C++ signature :
        std::vector<unsigned long, std::allocator<unsigned long> > get_synapses_from(nemo::Network {lvalue},unsigned int)
neuron_count(...)
neuron_count( (Network)arg1) -> int :
    
    
    
    
    Returns number of neurons in the network
 
    C++ signature :
        unsigned int neuron_count(nemo::Network {lvalue})
set_neuron(...)
object set_neuron(tuple args, dict kwds) :
    
    
    modify one or more existing neurons
    
    Inputs:
    idx -- Neuron index
    parameters... -- all neuron parameters
    state... -- all state variables
    
    The meaning of the parameters and state variables varies depending on the
    neuron type (specified when the neuron was created)This function may be
    called either in a scalar or vector form. In the scalar form all inputs are
    scalars. In the vector form, the neuron index argument plus any number of
    the other arguments are lists of the same length. In this second form
    scalar inputs are replicated the appropriate number of times
 
    C++ signature :
        object set_neuron(tuple args, dict kwds)
set_neuron_parameter(...)
set_neuron_parameter( (Network)arg1, (object)arg2, (int)arg3, (object)arg4) -> None :
    
    
    set neuron parameter
    
    Inputs:
    idx -- neuron index
    varno -- variable index
    val -- value of the neuron parameter
    
    The neuron parameters do not change during simulation. For the Izhikevich
    model: 0=a, 1=b, 2=c, 3=d. The neuron and value parameters can be either
    both scalar or both lists of the same length
 
    C++ signature :
        void set_neuron_parameter(nemo::Network {lvalue},_object*,unsigned int,_object*)
set_neuron_state(...)
set_neuron_state( (Network)arg1, (object)arg2, (int)arg3, (object)arg4) -> None :
    
    
    set neuron state variable
    
    Inputs:
    idx -- neuron index
    varno -- variable index
    val -- value of the relevant variable
    
    For the Izhikevich model: 0=u, 1=v. The neuron and value parameters can be
    either both scalar or both lists of the same length
 
    C++ signature :
        void set_neuron_state(nemo::Network {lvalue},_object*,unsigned int,_object*)

Data and other attributes defined here:
__instance_size__ = 40

Data descriptors inherited from Boost.Python.instance:
__dict__
__weakref__

Data and other attributes inherited from Boost.Python.instance:
__new__ = <built-in method __new__ of Boost.Python.class object>
T.__new__(S, ...) -> a new object with type S, a subtype of T

 
class Simulation(Boost.Python.instance)
    A simulation is created from a network and a configuration object. The
simulation is run by stepping through it, providing stimulus as
appropriate. It is possible to read back synapse data at run time. The
simulation also maintains a timer for both simulated time and wallclock
time.
 
 
Method resolution order:
Simulation
Boost.Python.instance
__builtin__.object

Methods defined here:
__init__(...)
__init__( (object)arg1, (Network)arg2, (Configuration)arg3) -> object :
 
    C++ signature :
        void* __init__(boost::python::api::object,nemo::Network,nemo::Configuration)
__reduce__ = (...)
apply_stdp(...)
apply_stdp( (Simulation)arg1, (float)arg2) -> None :
    
    
    update synapse weights using the accumulated STDP statistics
    
    Inputs:
    reward -- Multiplier for the accumulated weight change
 
    C++ signature :
        void apply_stdp(nemo::Simulation {lvalue},float)
elapsed_simulation(...)
elapsed_simulation( (Simulation)arg1) -> int :
    
    
    
    
    Returns number of milliseconds of simulation time elapsed since first simulation step (or last timer reset)
 
    C++ signature :
        unsigned long elapsed_simulation(nemo::Simulation {lvalue})
elapsed_wallclock(...)
elapsed_wallclock( (Simulation)arg1) -> int :
    
    
    
    
    Returns number of milliseconds of wall-clock time elapsed since first simulation step (or last timer reset)
 
    C++ signature :
        unsigned long elapsed_wallclock(nemo::Simulation {lvalue})
get_delays(*args, **kwargs)
get_membrane_potential(...)
get_membrane_potential( (Simulation)arg1, (object)arg2) -> object :
    
    
    get neuron membane potential
    
    Inputs:
    idx -- neuron index
    
    Returns membrane potential
    
    The neuron index may be either scalar or a list. The output has the same
    length as the neuron input
 
    C++ signature :
        _object* get_membrane_potential(nemo::Simulation {lvalue},_object*)
get_neuron_parameter(...)
get_neuron_parameter( (Simulation)arg1, (object)arg2, (int)arg3) -> object :
    
    
    get neuron parameter
    
    Inputs:
    idx -- neuron index
    varno -- variable index
    
    Returns value of the neuron parameter
    
    The neuron parameters do not change during simulation. For the Izhikevich
    model: 0=a, 1=b, 2=c, 3=d. The neuron index may be either scalar or a list.
    The output has the same length as the neuron input
 
    C++ signature :
        _object* get_neuron_parameter(nemo::Simulation {lvalue},_object*,unsigned int)
get_neuron_state(...)
get_neuron_state( (Simulation)arg1, (object)arg2, (int)arg3) -> object :
    
    
    get neuron state variable
    
    Inputs:
    idx -- neuron index
    varno -- variable index
    
    Returns value of the relevant variable
    
    For the Izhikevich model: 0=u, 1=v. The neuron index may be either scalar
    or a list. The output has the same length as the neuron input
 
    C++ signature :
        _object* get_neuron_state(nemo::Simulation {lvalue},_object*,unsigned int)
get_plastic(*args, **kwargs)
get_synapse_delay(...)
get_synapse_delay( (Simulation)arg1, (object)arg2) -> object :
    
    
    return the conduction delay for the specified synapse
    
    Inputs:
    synapse -- synapse id (as returned by addSynapse)
    
    Returns conduction delay of the specified synapse
    
    The input synapse indices may be either a scalar or a list. The return
    value has the same form
 
    C++ signature :
        _object* get_synapse_delay(nemo::Simulation,_object*)
get_synapse_plastic(...)
get_synapse_plastic( (Simulation)arg1, (object)arg2) -> object :
    
    
    return the boolean plasticity status for the specified synapse
    
    Inputs:
    synapse -- synapse id (as returned by addSynapse)
    
    Returns plasticity status of the specified synapse
    
    The input synapse indices may be either a scalar or a list. The return
    value has the same form
 
    C++ signature :
        _object* get_synapse_plastic(nemo::Simulation,_object*)
get_synapse_source(...)
get_synapse_source( (Simulation)arg1, (object)arg2) -> object :
    
    
    return the source neuron of the specified synapse
    
    Inputs:
    synapse -- synapse id (as returned by addSynapse)
    
    Returns source neuron index
    
    The input synapse indices may be either a scalar or a list. The return
    value has the same form
 
    C++ signature :
        _object* get_synapse_source(nemo::Simulation,_object*)
get_synapse_target(...)
get_synapse_target( (Simulation)arg1, (object)arg2) -> object :
    
    
    return the target of the specified synapse
    
    Inputs:
    synapse -- synapse id (as returned by addSynapse)
    
    Returns target neuron index
    
    The input synapse indices may be either a scalar or a list. The return
    value has the same form
 
    C++ signature :
        _object* get_synapse_target(nemo::Simulation,_object*)
get_synapse_weight(...)
get_synapse_weight( (Simulation)arg1, (object)arg2) -> object :
    
    
    return the weight for the specified synapse
    
    Inputs:
    synapse -- synapse id (as returned by addSynapse)
    
    Returns weight of the specified synapse
    
    The input synapse indices may be either a scalar or a list. The return
    value has the same form
 
    C++ signature :
        _object* get_synapse_weight(nemo::Simulation,_object*)
get_synapses_from(...)
get_synapses_from( (Simulation)arg1, (int)arg2) -> std_vector_uint64 :
    
    
    return the synapse ids for all synapses with the given source neuron
    
    Inputs:
    source -- source neuron index
    
    Returns synapse ids
    
    The input synapse indices may be either a scalar or a list. The return
    value has the same form
 
    C++ signature :
        std::vector<unsigned long, std::allocator<unsigned long> > get_synapses_from(nemo::Simulation {lvalue},unsigned int)
get_targets(*args, **kwargs)
get_weights(*args, **kwargs)
reset_timer(...)
reset_timer( (Simulation)arg1) -> None :
    
    
    reset both wall-clock and simulation timer
 
    C++ signature :
        void reset_timer(nemo::Simulation {lvalue})
set_neuron(...)
object set_neuron(tuple args, dict kwds) :
    
    
    modify one or more existing neurons
    
    Inputs:
    idx -- Neuron index
    parameters... -- all neuron parameters
    state... -- all state variables
    
    The meaning of the parameters and state variables varies depending on the
    neuron type (specified when the neuron was created)This function may be
    called either in a scalar or vector form. In the scalar form all inputs are
    scalars. In the vector form, the neuron index argument plus any number of
    the other arguments are lists of the same length. In this second form
    scalar inputs are replicated the appropriate number of times
 
    C++ signature :
        object set_neuron(tuple args, dict kwds)
set_neuron_parameter(...)
set_neuron_parameter( (Simulation)arg1, (object)arg2, (int)arg3, (object)arg4) -> None :
    
    
    set neuron parameter
    
    Inputs:
    idx -- neuron index
    varno -- variable index
    val -- value of the neuron parameter
    
    The neuron parameters do not change during simulation. For the Izhikevich
    model: 0=a, 1=b, 2=c, 3=d. The neuron and value parameters can be either
    both scalar or both lists of the same length
 
    C++ signature :
        void set_neuron_parameter(nemo::Simulation {lvalue},_object*,unsigned int,_object*)
set_neuron_state(...)
set_neuron_state( (Simulation)arg1, (object)arg2, (int)arg3, (object)arg4) -> None :
    
    
    set neuron state variable
    
    Inputs:
    idx -- neuron index
    varno -- variable index
    val -- value of the relevant variable
    
    For the Izhikevich model: 0=u, 1=v. The neuron and value parameters can be
    either both scalar or both lists of the same length
 
    C++ signature :
        void set_neuron_state(nemo::Simulation {lvalue},_object*,unsigned int,_object*)
step(self, fstim=None, istim=None)
run simulation for a single cycle (1ms)
 
Inputs:
fstim -- An optional list of neurons which will be forced to fire this cycle
istim -- An optional list of neuron index/current pairs for external stimulus of the network
step_f(...)
step_f( (Simulation)arg1, (std_vector_unsigned)arg2) -> std_vector_unsigned :
 
    C++ signature :
        std::vector<unsigned int, std::allocator<unsigned int> > step_f(nemo::Simulation {lvalue},std::vector<unsigned int, std::allocator<unsigned int> >)
step_fi(...)
step_fi( (Simulation)arg1, (std_vector_unsigned)arg2, (object)arg3) -> std_vector_unsigned :
 
    C++ signature :
        std::vector<unsigned int, std::allocator<unsigned int> > step_fi(nemo::Simulation {lvalue},std::vector<unsigned int, std::allocator<unsigned int> >,std::vector<std::pair<unsigned int, float>, std::allocator<std::pair<unsigned int, float> > >)
step_i(...)
step_i( (Simulation)arg1, (object)arg2) -> std_vector_unsigned :
 
    C++ signature :
        std::vector<unsigned int, std::allocator<unsigned int> > step_i(nemo::Simulation {lvalue},std::vector<std::pair<unsigned int, float>, std::allocator<std::pair<unsigned int, float> > >)
step_noinput(...)
step_noinput( (Simulation)arg1) -> std_vector_unsigned :
 
    C++ signature :
        std::vector<unsigned int, std::allocator<unsigned int> > step_noinput(nemo::Simulation {lvalue})

Data descriptors inherited from Boost.Python.instance:
__dict__
__weakref__

Data and other attributes inherited from Boost.Python.instance:
__new__ = <built-in method __new__ of Boost.Python.class object>
T.__new__(S, ...) -> a new object with type S, a subtype of T

 
Data
        __all__ = ['Network', 'Simulation', 'Configuration']
__version__ = '0.7.1'