Building models with the Nengo frontend API
involves constructing many objects,
each with many parameters that can be set.
To make setting all of these parameters easier,
Nengo has a config
system and
pre-set configurations.
config
system¶Nengo’s config
system is used for two important functions:
A tutorial-style introduction to the config
system
can be found below:
config
system API¶nengo.
Config
(*configures)[source]¶Configures network-level defaults and additional parameters.
Every Network
contains an associated Config
object which can
be manipulated to change network-specific defaults, and to store
additional parameters (for example, those specific to a backend).
A Config
object can configure objects of any class, but it has to be
told the classes to configure first. This is either done on instantiation
of the Config
object or by calling the configures
method.
This sets up a mapping between configured class and a ClassParams
object that sets the default values for that class. Attempting to
configure an instance of a configure class will create a mapping from
that instance to an InstanceParams
object to configure additional
parameters for that instance.
Parameters: |
|
---|
Examples
To configure defaults on a network:
net = nengo.Network()
net.config[nengo.Ensemble].radius = 1.5
with net:
ens = nengo.Ensemble(10, 1)
ens.radius == 1.5 # True
To add a new parameter to a Nengo object:
net.config[nengo.Ensemble].set_param(
'location', nengo.params.Parameter('location'))
net.config[ens].location = 'cortex'
To group together a set of parameters:
gaba = nengo.Config(nengo.Connection)
gaba[nengo.Connection].synapse = nengo.Lowpass(0.008)
with net, gaba:
conn = nengo.Connection(ens, ens)
conn.synapse == nengo.Lowpass(0.008) # True
To configure a new type of object:
class SynapseInfo(object):
label = nengo.params.StringParam('label')
gaba.configures(SynapseInfo)
gaba[SynapseInfo].label = "GABA" # Set default label
Attributes: |
|
---|
all_defaults
(nengo_cls=None)[source]¶Look up all of the default values in the current context.
Parameters: |
|
---|---|
Returns: |
|
default
(nengo_cls, param)[source]¶Look up the current default value for a parameter.
The default is found by going through the config stack, from most specific to least specific. The network that an object is in is the most specific; the top-level network is the least specific. If no default is found there, then the parameter’s default value is returned.
nengo.config.
ClassParams
(configures)[source]¶A class to store extra parameters and defaults on configured classes.
This is used by Config
to associate defaults and new Parameter
instances with existing objects. It should not be instantiated outside of
Config.configures
.
Parameters: |
|
---|
nengo.config.
InstanceParams
(configures, clsparams)[source]¶A class to store parameter value on configured objects.
In contrast to ClassParams
, the only thing that can be done with
InstanceParams
is get and set parameter values. Use the corresponding
ClassParams
to set defaults and create new parameters.
Nengo includes preset configurations that can be dropped into your model to enable specific neural circuits.
nengo.presets.
ThresholdingEnsembles
(threshold, intercept_width=0.15, radius=1.0)[source]¶Configuration preset for a thresholding ensemble.
This preset adjust ensemble parameters for thresholding. The ensemble’s neurons will only fire for values above threshold. One can either decode the represented value (if it is above the threshold) or decode a step function if binary classification is desired.
This preset:
threshold
and radius
with an
exponential distribution (shape parameter of intercept_width
).
This clusters intercepts near the threshold for better approximation.threshold
and radius
.Parameters: |
|
---|---|
Returns: |
|