public class NEFEnsembleImpl extends DecodableEnsembleImpl implements NEFEnsemble
VisiblyMutable.Event, VisiblyMutable.Listener, VisiblyMutable.NameChangeEvent, VisiblyMutable.NodeRemovedEvent
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
BIAS_SUFFIX
Append to bias termination names
|
static java.lang.String |
INTERNEURON_SUFFIX
Append to interneuron names
|
myDecodedOrigins, myDecodedTerminations
myPlasticEnsembleTerminations
myExpandableNodes, myExpandedTerminations
X
Constructor and Description |
---|
NEFEnsembleImpl(java.lang.String name,
NEFNode[] nodes,
float[][] encoders,
ApproximatorFactory factory,
float[][] evalPoints,
float[] radii) |
Modifier and Type | Method and Description |
---|---|
Termination |
addBCMTermination(java.lang.String name,
float[][] weights,
float tauPSC,
boolean modulatory,
float[] theta) |
BiasOrigin |
addBiasOrigin(Origin existing,
int numInterneurons,
java.lang.String name,
boolean excitatory)
Adds a BiasOrigin, which operates in parallel with an existing Origin, such that the effective weights of the
two origins together are all of the same sign (as is normally the case with synaptic weights in the brain).
|
BiasTermination[] |
addBiasTerminations(DecodedTermination baseTermination,
float interneuronTauPSC,
float[][] biasDecoders,
float[][] functionDecoders)
Adds BiasTerminations, which are meant to receive projections from BiasOrigins.
|
Origin |
addDecodedOrigin(DecodedOrigin o)
Adds the given DecodedOrigin to this ensemble.
|
Origin |
addDecodedOrigin(java.lang.String name,
Function[] functions,
java.lang.String nodeOrigin)
Adds an Origin that corresponds to a decoding of the activities of Nodes in this Ensemble.
|
Origin |
addDecodedSignalOrigin(java.lang.String name,
TimeSeries targetSignal,
TimeSeries[] evalSignals,
java.lang.String nodeOrigin)
Similar to addDecodedOrigin, but uses a target signal and evaluation signals (over time) rather than a target function
and evaluation points.
|
Termination |
addDecodedTermination(java.lang.String name,
float[][] matrix,
float[] tfNumerator,
float[] tfDenominator,
float passthrough,
boolean isModulatory)
As above but with arbitrary single-input-single-output PSC dynamics.
|
Termination |
addDecodedTermination(java.lang.String name,
float[][] matrix,
float tauPSC,
boolean isModulatory)
Adds a new Termination into this Ensemble, at which information is to be received
in the form of decoded state variables rather than spikes, etc.
|
Termination |
addHPESTermination(java.lang.String name,
float[][] weights,
float tauPSC,
boolean modulatory,
float[] theta) |
Termination |
addPESTermination(java.lang.String name,
float[][] weights,
float tauPSC,
boolean modulatory) |
Termination |
addPreLearnTermination(java.lang.String name,
float[][] weights,
float tauPSC,
boolean modulatory) |
NEFEnsembleImpl |
clone() |
void |
fixMode()
When this method is called, the mode of this node is fixed and cannot be changed by
subsequent setMode(...) calls.
|
void |
fixMode(SimulationMode[] modes)
Set the allowed simulation modes.
|
protected float[] |
getConstantOutput(int nodeIndex,
float[][] evalPoints,
java.lang.String origin) |
protected float[][] |
getConstantOutputs(float[][] evalPoints,
java.lang.String origin) |
LinearApproximator |
getDecodingApproximator(java.lang.String nodeName) |
int |
getDimension() |
DynamicalSystem |
getDirectModeDynamics() |
Integrator |
getDirectModeIntegrator() |
float[][] |
getEncoders() |
NEFEnsembleFactory |
getEnsembleFactory() |
float[][] |
getEvalPoints() |
int |
getNeuronCount() |
int |
getNeurons() |
int |
getNodeCount() |
float |
getRadialInput(float[] state,
int node) |
float[] |
getRadii() |
boolean |
getReuseApproximators() |
protected float[][] |
getSignalOutput(int nodeIndex,
TimeSeries[] evalSignals,
java.lang.String origin)
Similar to getConstantOutput, but uses a time series as input to each neuron rather than a single point.
|
protected float[][][] |
getSignalOutputs(TimeSeries[] evalSignals,
java.lang.String origin)
Similar to getConstantOutputs, but uses a time series as input to each neuron rather than a single point.
|
float[] |
getStaticNeuronData()
Used to get static neuron data (data that doesn't change each step) and give it to the GPU.
|
boolean |
getUseGPU() |
void |
killNeurons(float killrate,
boolean saveRelays)
Stops a given percentage of neurons in this population from firing.
|
java.util.Properties |
listStates() |
void |
releaseMemory()
Releases any memory that can be freed.
|
void |
reset(boolean randomize)
Resets each Node in this Ensemble.
|
void |
run(float startTime,
float endTime)
Runs each neuron in the Ensemble.
|
void |
setDirectModeDynamics(DynamicalSystem dynamics) |
void |
setDirectModeIntegrator(Integrator integrator) |
void |
setEncoders(float[][] encoders) |
void |
setEnsembleFactory(NEFEnsembleFactory factory)
Gives the ensemble a reference to the factory used to created it (useful for adding more neurons later)
|
void |
setEvalPoints(float[][] evalPoints)
Note: by-products of decoding are sometimes cached, so if these are changed it may be
necessary to call setReuseApproximators(false) for the change to take effect.
|
void |
setMode(SimulationMode mode)
This Ensemble does not support SimulationMode.DIRECT.
|
void |
setNeurons(int count)
TODO: figure out why I have to add these so that it will show up in the Configure menu
(nodeCount doens't appear for some reason)
|
void |
setNodeCount(int n) |
void |
setRadii(float[] radii) |
void |
setReuseApproximators(boolean reuse) |
void |
setUseGPU(boolean use) |
java.lang.String |
toScript(java.util.HashMap<java.lang.String,java.lang.Object> scriptData) |
addDecodedOrigin, addDecodedOrigin, addDecodedOrigin, doneOrigins, getApproximatorFactory, getDecodedOrigins, getDecodedTerminations, getHistory, getOrigin, getOrigins, getTermination, getTerminations, removeDecodedOrigin, removeDecodedTermination, setTime, stopProbing
addTasks, getLearning, getPlasticityInterval, getTasks, isPopulationPlastic, setLearning, setPlasticityInterval, setStates, setTasks
addTermination, addTermination, getChildren, notifyAboutDeletion, removeTermination
addChangeListener, collectSpikes, findCommon1DOrigins, fireVisibleChangeEvent, getCollectSpikesRatio, getDocumentation, getMetadata, getMode, getName, getNodes, getSpikePattern, isCollectingSpikes, redefineNodes, removeChangeListener, removeOrigin, setCollectSpikesRatio, setDocumentation, setMetadata, setName, setSpikePattern
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addDecodedOrigin, addDecodedOrigin, doneOrigins, removeDecodedOrigin, removeDecodedTermination
getPlasticityInterval, setPlasticityInterval
collectSpikes, getNodes, getSpikePattern, isCollectingSpikes, redefineNodes, stopProbing
getChildren, getDocumentation, getName, getOrigin, getOrigins, getTermination, getTerminations, notifyAboutDeletion, setDocumentation, setName
getMode
addChangeListener, removeChangeListener
getHistory
public static java.lang.String BIAS_SUFFIX
public static java.lang.String INTERNEURON_SUFFIX
public NEFEnsembleImpl(java.lang.String name, NEFNode[] nodes, float[][] encoders, ApproximatorFactory factory, float[][] evalPoints, float[] radii) throws StructuralException
name
- Unique name of Ensemblenodes
- Nodes that make up the Ensembleencoders
- List of encoding vectors (one for each node). All must have same lengthfactory
- Source of LinearApproximators to use in decoding outputevalPoints
- Vector inputs at which output is found to produce DecodedOriginsradii
- Radius for each dimensionStructuralException
- if there are a different number of Nodes than encoding vectors or if not
all encoders have the same lengthpublic float[] getRadii()
getRadii
in interface NEFEnsemble
NEFEnsemble.getRadii()
public void setUseGPU(boolean use)
use
- Use GPU?public boolean getUseGPU()
public void setRadii(float[] radii) throws StructuralException
radii
- A list of radii of encoded area along each dimension; uniform
radius along each dimension can be specified with a list of length 1StructuralException
- if getConstantOutputs throws exceptionpublic void setEvalPoints(float[][] evalPoints)
evalPoints
- Points in the encoded space at which node outputs are evaluated for
establishing new DecodedOrigins.public float[][] getEvalPoints()
public void setDirectModeDynamics(DynamicalSystem dynamics)
dynamics
- DynamicalSystem that models internal neuron dynamics at the ensemble level, when
the ensemble runs in direct mode. The input and output dimensions must equal the dimension of the
ensemble.public DynamicalSystem getDirectModeDynamics()
public Integrator getDirectModeIntegrator()
public void setDirectModeIntegrator(Integrator integrator)
integrator
- Integrator to use in direct modeprotected float[][] getConstantOutputs(float[][] evalPoints, java.lang.String origin) throws StructuralException
evalPoints
- Vector points at which to find output (each one must have same dimension as
encoder)origin
- Name of Origin from which to collect output for each NodeStructuralException
- If CONSTANT_RATE is not supported by any Nodeprotected float[] getConstantOutput(int nodeIndex, float[][] evalPoints, java.lang.String origin) throws StructuralException, SimulationException
nodeIndex
- Index of Node for which to find output at various inputsevalPoints
- Vector points at which to find output (each one must have same dimension as
encoder)origin
- Name of Origin from which to collect outputStructuralException
- If CONSTANT_RATE is not supported by the given NodeSimulationException
- If the Node does not have an Origin with the given nameprotected float[][][] getSignalOutputs(TimeSeries[] evalSignals, java.lang.String origin) throws StructuralException
evalPoints
- Signals over which to evaluate outputs. Each signal can have dimension
equal to the number of nodes in the population (each dimension is the input to one node),
or dimension equal to the dimension of this population (a single input for the whole population).origin
- Name of Origin from which to collect output for each NodeStructuralException
- If RATE is not supported by any Nodeprotected float[][] getSignalOutput(int nodeIndex, TimeSeries[] evalSignals, java.lang.String origin) throws StructuralException, SimulationException
nodeIndex
- Index of Node for which to find output at various inputsevalPoints
- Signals over which to evaluate outputs. Each signal can have dimension
equal to the number of nodes in the population (each dimension is the input to one node),
or dimension equal to the dimension of this population (a single input for the whole population).origin
- Name of Origin from which to collect outputStructuralException
- If RATE is not supported by the given NodeSimulationException
- If the Node does not have an Origin with the given namepublic int getDimension()
getDimension
in interface ExpandableNode
getDimension
in interface NEFEnsemble
getDimension
in class EnsembleImpl
NEFEnsemble.getDimension()
public float[][] getEncoders()
getEncoders
in interface NEFEnsemble
NEFEnsemble.getEncoders()
public void setEncoders(float[][] encoders)
encoders
- New encoding vectors (row per Node)public boolean getReuseApproximators()
public void setReuseApproximators(boolean reuse)
reuse
- True if LinearApproximators for a Node Origin are re-used for decoding multiple decoded Origins.public Origin addDecodedOrigin(java.lang.String name, Function[] functions, java.lang.String nodeOrigin) throws StructuralException
NEFEnsemble
addDecodedOrigin
in interface NEFEnsemble
name
- Name of decodingfunctions
- Functions that define the decoding (one function for each dimension of output).
All functions must have an input dimension equal to the dimension of this NEFEnsemble.nodeOrigin
- Name of the Node-level Origins from which this Ensemble-level Origin is derived
(often Neuron.AXON)StructuralException
- if functions do not all have the same input dimension as the
dimension of this ensembleNEFEnsemble.addDecodedOrigin(java.lang.String, Function[], String)
public Origin addDecodedSignalOrigin(java.lang.String name, TimeSeries targetSignal, TimeSeries[] evalSignals, java.lang.String nodeOrigin) throws StructuralException
name
- Name of origintargetSignal
- signal that the origin should produceevalSignals
- evaluation signals used to calculate decodersnodeOrigin
- origin from which to draw output from each nodeStructuralException
public Origin addDecodedOrigin(DecodedOrigin o)
o
- the origin to be addedpublic BiasOrigin addBiasOrigin(Origin existing, int numInterneurons, java.lang.String name, boolean excitatory) throws StructuralException
NEFEnsemble
addBiasOrigin
in interface NEFEnsemble
existing
- An existing Origin on this NEFEnsemblenumInterneurons
- Number of interneuronsname
- Name of BiasOrigin (name of associated interneuron ensemble is also derived from this)excitatory
- If true, effective weights will be positive; if false they will be negative (inhibitory)StructuralException
- if given Origin is not a DecodedOrigin or if there is a construction problemNEFEnsemble.addBiasOrigin(ca.nengo.model.Origin, int, java.lang.String, boolean)
public Termination addDecodedTermination(java.lang.String name, float[][] matrix, float tauPSC, boolean isModulatory) throws StructuralException
NEFEnsemble
addDecodedTermination
in interface NEFEnsemble
addDecodedTermination
in class DecodableEnsembleImpl
name
- Unique name for this Termination (in the scope of this Ensemble)matrix
- Transformation matrix which defines a linear map on incoming information,
onto the space of vectors that can be represented by this NEFEnsemble. The first dimension
is taken as matrix rows, and must have the same length as the Origin that will be connected
to this Termination. The second dimension is taken as matrix columns, and must have the same
length as the encoders of this NEFEnsemble. TODO: this is transposed?tauPSC
- Time constant of post-synaptic current decay (all Terminations have
this property but it may have slightly different interpretations depending other properties
of the Termination).isModulatory
- If true, inputs to this Termination do not drive Nodes in the Ensemble directly
but may have modulatory influences (eg related to plasticity). If false, the transformation matrix
output dimension must match the dimension of this Ensemble.StructuralException
- if termination name is takenNEFEnsemble.addDecodedTermination(java.lang.String, float[][], float, boolean)
public Termination addDecodedTermination(java.lang.String name, float[][] matrix, float[] tfNumerator, float[] tfDenominator, float passthrough, boolean isModulatory) throws StructuralException
NEFEnsemble
addDecodedTermination
in interface NEFEnsemble
addDecodedTermination
in class DecodableEnsembleImpl
name
- Unique name for this Termination (in the scope of this Ensemble)matrix
- Transformation matrix which defines a linear map on incoming information,
onto the space of vectors that can be represented by this NEFEnsemble. The first dimension
is taken as matrix rows, and must have the same length as the Origin that will be connected
to this Termination. The second dimension is taken as matrix columns, and must have the same
length as the encoders of this NEFEnsemble. TODO: this is transposed?tfNumerator
- Coefficients of transfer function numerator (see CanonicalModel.getRealization(...)
for details)tfDenominator
- Coefficients of transfer function denominatorpassthrough
- How much should pass through?isModulatory
- Is the termination modulatory?StructuralException
- if termination name is takenNEFEnsemble.addDecodedTermination(java.lang.String, float[][], float[], float[], float, boolean)
public Termination addPESTermination(java.lang.String name, float[][] weights, float tauPSC, boolean modulatory) throws StructuralException
name
- Unique name for the Termination (in the scope of this Node)weights
- Each row is used as a 1 by m matrix of weights in a new termination on the nth expandable nodetauPSC
- Time constant with which incoming signals are filtered. (All Terminations have
this property, but it may have slightly different interpretations per implementation.)modulatory
- If true, inputs to the Termination are not summed with other inputs (they
only have modulatory effects, eg on plasticity, which must be defined elsewhere).StructuralException
- if weight matrix dimensionality is incorrectExpandableNode.addTermination(java.lang.String, float[][], float, boolean)
public Termination addHPESTermination(java.lang.String name, float[][] weights, float tauPSC, boolean modulatory, float[] theta) throws StructuralException
name
- Unique name for the Termination (in the scope of this Node)weights
- Each row is used as a 1 by m matrix of weights in a new termination on the nth expandable nodetauPSC
- Time constant with which incoming signals are filtered. (All Terminations have
this property, but it may have slightly different interpretations per implementation.)modulatory
- If true, inputs to the Termination are not summed with other inputs (they
only have modulatory effects, eg on plasticity, which must be defined elsewhere).StructuralException
- if weight matrix dimensionality is incorrectExpandableNode.addTermination(java.lang.String, float[][], float, boolean)
public Termination addBCMTermination(java.lang.String name, float[][] weights, float tauPSC, boolean modulatory, float[] theta) throws StructuralException
name
- Unique name for the Termination (in the scope of this Node)weights
- Each row is used as a 1 by m matrix of weights in a new termination on the nth expandable nodetauPSC
- Time constant with which incoming signals are filtered. (All Terminations have
this property, but it may have slightly different interpretations per implementation.)modulatory
- If true, inputs to the Termination are not summed with other inputs (they
only have modulatory effects, eg on plasticity, which must be defined elsewhere).StructuralException
- if weight matrix dimensionality is incorrectExpandableNode.addTermination(java.lang.String, float[][], float, boolean)
public Termination addPreLearnTermination(java.lang.String name, float[][] weights, float tauPSC, boolean modulatory) throws StructuralException
StructuralException
public BiasTermination[] addBiasTerminations(DecodedTermination baseTermination, float interneuronTauPSC, float[][] biasDecoders, float[][] functionDecoders) throws StructuralException
NEFEnsemble
addBiasTerminations
in interface NEFEnsemble
baseTermination
- The Termination that is to be biased (so that projections to it consist of weights of a single sign)interneuronTauPSC
- Time constant of post-synaptic current decay of inhibitory termination from interneurons onto this ensemblebiasDecoders
- The decoding weights of the associated BiasOriginfunctionDecoders
- The decoding vectors of the BiasOrigin's associated base originStructuralException
- if can't be addedNEFEnsemble.addBiasTerminations(ca.nengo.model.nef.impl.DecodedTermination, float, float[][], float[][])
public void run(float startTime, float endTime) throws SimulationException
AbstractEnsemble
run
in interface Node
run
in class DecodableEnsembleImpl
startTime
- simulation time at which running starts (s)endTime
- simulation time at which running ends (s)SimulationException
- if a problem is encountered while trying to runNode.run(float, float)
public float getRadialInput(float[] state, int node)
state
- State vectornode
- Node numberpublic void setMode(SimulationMode mode)
EnsembleImpl
setMode
in interface SimulationMode.ModeConfigurable
setMode
in class EnsembleImpl
mode
- SimulationMode in which it is desired that the object runs.SimulationMode.ModeConfigurable.setMode(ca.nengo.model.SimulationMode)
public void fixMode()
public void fixMode(SimulationMode[] modes)
public void reset(boolean randomize)
AbstractEnsemble
reset
in interface Resettable
reset
in class DecodableEnsembleImpl
randomize
- True indicates that the object should be reset to a
randomly selected initial state (the object must be aware of the
distribution from which to draw from). False indicates that the
object should be reset to a fixed initial state (which it must
also know). Some objects may not support randomization of the initial
state, in which case a fixed state will be used in either case.Resettable.reset(boolean)
public void setEnsembleFactory(NEFEnsembleFactory factory)
NEFEnsemble
setEnsembleFactory
in interface NEFEnsemble
factory
- Factory that created the ensemblepublic NEFEnsembleFactory getEnsembleFactory()
getEnsembleFactory
in interface NEFEnsemble
public LinearApproximator getDecodingApproximator(java.lang.String nodeName)
public int getNodeCount()
getNodeCount
in interface NEFEnsemble
public int getNeuronCount()
public void setNodeCount(int n) throws StructuralException
setNodeCount
in interface NEFEnsemble
n
- number of desired neuronsStructuralException
- if we can't add them or there is no factorypublic java.util.Properties listStates()
listStates
in interface Probeable
listStates
in class DecodableEnsembleImpl
Probeable.listStates()
public java.lang.String toScript(java.util.HashMap<java.lang.String,java.lang.Object> scriptData) throws ScriptGenException
toScript
in interface Node
toScript
in class EnsembleImpl
scriptData
- Map of class parent and prefix data for generating python scriptScriptGenException
- if the node cannot be generated in scriptpublic NEFEnsembleImpl clone() throws java.lang.CloneNotSupportedException
clone
in interface ExpandableNode
clone
in interface Node
clone
in class DecodableEnsembleImpl
java.lang.CloneNotSupportedException
- if clone can't be madepublic void releaseMemory()
releaseMemory
in interface NEFEnsemble
public void setNeurons(int count) throws StructuralException
count
- number of desired neuronsStructuralException
- if factory doesn't exist or can't add that manypublic int getNeurons()
public float[] getStaticNeuronData()
public void killNeurons(float killrate, boolean saveRelays)
killrate
- the percentage of neurons to stop firingsaveRelays
- if true, do nothing if there is only one node in this population