Nengo.ca

ca.nengo.model.impl
Class NetworkArrayImpl

java.lang.Object
  extended by ca.nengo.model.impl.NetworkImpl
      extended by ca.nengo.model.impl.NetworkArrayImpl
All Implemented Interfaces:
Network, Node, Probeable, Resettable, SimulationMode.ModeConfigurable, TaskSpawner, VisiblyMutable, VisiblyMutable.Listener, java.io.Serializable, java.lang.Cloneable

public class NetworkArrayImpl
extends NetworkImpl

Default implementation of Network Array.

See Also:
Serialized Form

Nested Class Summary
 class NetworkArrayImpl.ArrayOrigin
          Origin representing the concatenation of origins on each of the ensembles within the network array.
static interface NetworkArrayImpl.WeightFunc
           
 
Nested classes/interfaces inherited from class ca.nengo.model.impl.NetworkImpl
NetworkImpl.OriginWrapper, NetworkImpl.TerminationWrapper
 
Nested classes/interfaces inherited from interface ca.nengo.util.VisiblyMutable
VisiblyMutable.Event, VisiblyMutable.Listener, VisiblyMutable.NameChangeEvent, VisiblyMutable.NodeRemovedEvent
 
Field Summary
 
Fields inherited from class ca.nengo.model.impl.NetworkImpl
DEFAULT_NAME, myNumGPU, myNumJavaThreads, myUseGPU
 
Constructor Summary
NetworkArrayImpl(java.lang.String name, NEFEnsembleImpl[] nodes)
          Create a network holding an array of nodes.
 
Method Summary
 Origin addDecodedOrigin(java.lang.String name, Function[] functions, java.lang.String nodeOrigin)
          Create a new Origin.
 Termination addDecodedTermination(java.lang.String name, float[][] matrix, float tauPSC)
          Create a new decoded termination.
 Termination addDecodedTermination(java.lang.String name, float[][] matrix, float tauPSC, boolean modulatory)
           
 Termination addIndexTermination(java.lang.String name, float[][] matrix, float tauPSC)
          Create a new termination.
 Termination addIndexTermination(java.lang.String name, float[][] matrix, float tauPSC, boolean isModulatory)
           
 Termination addIndexTermination(java.lang.String name, float[][] matrix, float tauPSC, boolean isModulatory, int[] index)
           
 Termination addIndexTermination(java.lang.String name, float[][] matrix, float tauPSC, int[] index)
           
 Termination addPlasticTermination(java.lang.String name, float[][] weights, float tauPSC, float[][] decoders)
           
 Termination addPlasticTermination(java.lang.String name, float[][] weights, float tauPSC, float[][] decoders, NetworkArrayImpl.WeightFunc weightFunc)
          Create a new plastic termination.
 Termination addTermination(java.lang.String name, float[][][] matrix, float tauPSC)
          Create a new termination.
 Termination addTermination(java.lang.String name, float[][][] weights, float tauPSC, boolean modulatory)
           
 Termination addTermination(java.lang.String name, float[][] matrix, float tauPSC)
          Create a new termination.
 Termination addTermination(java.lang.String name, float[][] weights, float tauPSC, boolean modulatory)
           
 void createEnsembleOrigin(java.lang.String name)
          Create an Origin that concatenates the values of internal Origins.
 void exposeAxons()
          Exposes the AXON terminations of each ensemble in the network.
 int getDimension()
           
 float[][] getEncoders()
          Returns the encoders for the whole network array (the encoders of each population within the array concatenated together).
 TimeSeries getHistory(java.lang.String stateName)
          Note that the units of TimeSeries' for a given state do not change over time (ie at different time steps).
 int getNeurons()
           
 int[] getNodeDimension()
           
 Node[] getNodes()
          Gets the nodes in the proper order from the network array.
 Termination[] getTerminations()
           
 void learn(java.lang.String learnTerm, java.lang.String modTerm, float rate)
          Sets learning parameters on learned terminations in the array.
 void learn(java.lang.String learnTerm, java.lang.String modTerm, float rate, boolean oja)
          Sets learning parameters on learned terminations in the array.
 java.util.Properties listStates()
           
 void releaseMemory()
          Releases memory of all ensembles in the network.
 void setLearning(boolean learn)
          Sets learning on/off for all ensembles in the network.
 
Methods inherited from class ca.nengo.model.impl.NetworkImpl
addChangeListener, addNode, addProjection, addStepListener, addTasks, changed, clone, countNeurons, dumpToScript, dumpToScript, exposeOrigin, exposeState, exposeTermination, fireStepListeners, fixMode, getChildren, getDocumentation, getExposedOriginName, getExposedTerminationName, getMetaData, getMode, getName, getNeuronCount, getNode, getNodeCount, getNodeOrigins, getNodeTerminations, getOrigin, getOrigins, getProjectionMap, getProjections, getSimulator, getStepSize, getTasks, getTermination, getUseGPU, hideOrigin, hideState, hideTermination, killNeurons, killNeurons, removeChangeListener, removeNode, removeProjection, removeStepListener, reset, run, run, setDocumentation, setMetaData, setMode, setMyMode, setName, setSimulator, setStepSize, setTasks, setTime, setUseGPU, toPostScript, toScript
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NetworkArrayImpl

public NetworkArrayImpl(java.lang.String name,
                        NEFEnsembleImpl[] nodes)
                 throws StructuralException
Create a network holding an array of nodes. An 'X' Origin is automatically created which concatenates the values of each internal element's 'X' Origin. This object is meant to be created using :func:`nef.Network.make_array()`, allowing for the efficient creation of neural groups that can represent large vectors. For example, the following code creates a NetworkArray consisting of 50 ensembles of 1000 neurons, each of which represents 10 dimensions, resulting in a total of 500 dimensions represented:: net=nef.Network('Example Array') A=net.make_array('A',neurons=1000,length=50,dimensions=10,quick=True) The resulting NetworkArray object can be treated like a normal ensemble, except for the fact that when computing nonlinear functions, you cannot use values from different ensembles in the computation, as per NEF theory.

Parameters:
name - The name of the NetworkArray to create
nodes - The ca.nengo.model.nef.NEFEnsemble nodes to combine together
Throws:
StructuralException
Method Detail

createEnsembleOrigin

public void createEnsembleOrigin(java.lang.String name)
                          throws StructuralException
Create an Origin that concatenates the values of internal Origins.

Parameters:
name - The name of the Origin to create. Each internal node must already have an Origin with that name.
Throws:
StructuralException

getNeurons

public int getNeurons()

addDecodedOrigin

public Origin addDecodedOrigin(java.lang.String name,
                               Function[] functions,
                               java.lang.String nodeOrigin)
                        throws StructuralException
Create a new Origin. A new origin is created on each of the ensembles, and these are grouped together to create an output. This method uses the same signature as ca.nengo.model.nef.NEFEnsemble.addDecodedOrigin()

Parameters:
name - The name of the newly created origin
functions - A list of ca.nengo.math.Function objects to approximate at this origin
nodeOrigin - Name of the base Origin to use to build this function approximation (this will always be 'AXON' for spike-based synapses)
Returns:
Origin that encapsulates all of the internal node origins
Throws:
StructuralException

addTermination

public Termination addTermination(java.lang.String name,
                                  float[][] matrix,
                                  float tauPSC)
                           throws StructuralException
Create a new termination. A new termination is created on each of the ensembles, which are then grouped together. This termination does not use NEF-style encoders; instead, the matrix is the actual connection weight matrix. Often used for adding an inhibitory connection that can turn off the whole array (by setting *matrix* to be all -10, for example).

Parameters:
name - The name of the newly created termination
weights - Synaptic connection weight matrix (NxM where N is the total number of neurons in the NetworkArray)
tauPSC - Post-synaptic time constant
modulatory - Boolean value that is False for normal connections, True for modulatory connections (which adjust neural properties rather than the input current)
Returns:
Termination that encapsulates all of the internal node terminations
Throws:
StructuralException

addTermination

public Termination addTermination(java.lang.String name,
                                  float[][] weights,
                                  float tauPSC,
                                  boolean modulatory)
                           throws StructuralException
Throws:
StructuralException

addTermination

public Termination addTermination(java.lang.String name,
                                  float[][][] matrix,
                                  float tauPSC)
                           throws StructuralException
Create a new termination. A new termination is created on each of the ensembles, which are then grouped together. This termination does not use NEF-style encoders; instead, the matrix is the actual connection weight matrix. Often used for adding an inhibitory connection that can turn off the whole array (by setting *matrix* to be all -10, for example).

Parameters:
name - The name of the newly created termination
weights - Synaptic connection weight matrix (LxNxM where L is the number of nodes in the array, N is the number of neurons in each node, and M is the dimensionality of each node)
tauPSC - Post-synaptic time constant
modulatory - Boolean value that is False for normal connections, True for modulatory connections (which adjust neural properties rather than the input current)
Returns:
Termination that encapsulates all of the internal node terminations
Throws:
StructuralException

addTermination

public Termination addTermination(java.lang.String name,
                                  float[][][] weights,
                                  float tauPSC,
                                  boolean modulatory)
                           throws StructuralException
Throws:
StructuralException

addDecodedTermination

public Termination addDecodedTermination(java.lang.String name,
                                         float[][] matrix,
                                         float tauPSC)
                                  throws StructuralException
Create a new decoded termination. A new termination is created on each of the ensembles, which are then grouped together.

Parameters:
name - The name of the newly created termination
matrix - Transformation matrix which defines a linear map on incoming information, onto the space of vectors that can be represented by this NetworkArray. The first dimension is taken as matrix columns, and must have the same length as the Origin that will be connected to this Termination. The second dimension is taken as matrix rows, and must have the same length as the encoders of this NEFEnsemble.
tauPSC - Post-synaptic time constant
modulatory - Boolean value that is False for normal connections, True for modulatory connections (which adjust neural properties rather than the input current)
Returns:
Termination that encapsulates all of the internal node terminations
Throws:
StructuralException

addDecodedTermination

public Termination addDecodedTermination(java.lang.String name,
                                         float[][] matrix,
                                         float tauPSC,
                                         boolean modulatory)
                                  throws StructuralException
Throws:
StructuralException

addIndexTermination

public Termination addIndexTermination(java.lang.String name,
                                       float[][] matrix,
                                       float tauPSC)
                                throws StructuralException
Create a new termination. A new termination is created on the specified ensembles, which are then grouped together. This termination does not use NEF-style encoders; instead, the matrix is the actual connection weight matrix. Often used for adding an inhibitory connection that can turn off selected ensembles within the array (by setting *matrix* to be all -10, for example).

Parameters:
string - name: the name of the newly created origin
matrix: - synaptic connection weight matrix (NxM where M is the total number of neurons in the ensembles to be connected)
float - tauPSC: post-synaptic time constant
boolean - isModulatory: False for normal connections, True for modulatory connections (which adjust neural properties rather than the input current)
index: - The indexes of the ensembles to connect to. If set to None, this function behaves exactly like addTermination().
Returns:
the new termination
Throws:
StructuralException

addIndexTermination

public Termination addIndexTermination(java.lang.String name,
                                       float[][] matrix,
                                       float tauPSC,
                                       boolean isModulatory)
                                throws StructuralException
Throws:
StructuralException

addIndexTermination

public Termination addIndexTermination(java.lang.String name,
                                       float[][] matrix,
                                       float tauPSC,
                                       int[] index)
                                throws StructuralException
Throws:
StructuralException

addIndexTermination

public Termination addIndexTermination(java.lang.String name,
                                       float[][] matrix,
                                       float tauPSC,
                                       boolean isModulatory,
                                       int[] index)
                                throws StructuralException
Throws:
StructuralException

getNodes

public Node[] getNodes()
Gets the nodes in the proper order from the network array. The NetworkImpl version of this function relies on the nodeMap object which is sometimes out of order.

Specified by:
getNodes in interface Network
Overrides:
getNodes in class NetworkImpl
Returns:
the nodes in this network array
See Also:
Network.getNodes()

getTerminations

public Termination[] getTerminations()
Specified by:
getTerminations in interface Node
Overrides:
getTerminations in class NetworkImpl
Returns:
Sets of input channels (these have the same dimension as corresponding Origins to which they are connected).
See Also:
Node.getTerminations()

addPlasticTermination

public Termination addPlasticTermination(java.lang.String name,
                                         float[][] weights,
                                         float tauPSC,
                                         float[][] decoders)
                                  throws StructuralException
Throws:
StructuralException

addPlasticTermination

public Termination addPlasticTermination(java.lang.String name,
                                         float[][] weights,
                                         float tauPSC,
                                         float[][] decoders,
                                         NetworkArrayImpl.WeightFunc weightFunc)
                                  throws StructuralException
Create a new plastic termination. A new termination is created on each of the ensembles, which are then grouped together.

Parameters:
name - The name of the newly created PES termination
weights - Synaptic connection weight matrix (NxM where N is the total number of neurons in the NetworkArray)
tauPSC - Post-synaptic time constant (which adjust neural properties rather than the input current)
weightFunc - object wrapping a function that consumes a weight matrix and returns a modified weight matrix
Returns:
Termination that encapsulates all of the internal node terminations
Throws:
StructuralException

getNodeDimension

public int[] getNodeDimension()

getDimension

public int getDimension()
See Also:
NEFEnsemble.getDimension()

exposeAxons

public void exposeAxons()
                 throws StructuralException
Exposes the AXON terminations of each ensemble in the network.

Throws:
StructuralException

listStates

public java.util.Properties listStates()
Specified by:
listStates in interface Probeable
Overrides:
listStates in class NetworkImpl
Returns:
List of state variable names, eg "V", and associated descriptions eg "membrane potential (mV)"
See Also:
Probeable.listStates()

getHistory

public TimeSeries getHistory(java.lang.String stateName)
                      throws SimulationException
Description copied from interface: Probeable
Note that the units of TimeSeries' for a given state do not change over time (ie at different time steps). CAUTION: The TimeSeries should not contain a reference to any arrays that you are going to change later. The caller owns what you return.

Specified by:
getHistory in interface Probeable
Overrides:
getHistory in class NetworkImpl
Parameters:
stateName - A state variable name
Returns:
History of values for the named state variable. The history must cover the most recent network time step, and no more. There should be no overlap in the time points returned for different steps.
Throws:
SimulationException - if the Probeable does not have the requested state
See Also:
Probeable.getHistory(java.lang.String)

learn

public void learn(java.lang.String learnTerm,
                  java.lang.String modTerm,
                  float rate)
Sets learning parameters on learned terminations in the array.

Parameters:
learnTerm - name of the learned termination
modTerm - name of the modulatory termination
rate - learning rate

learn

public void learn(java.lang.String learnTerm,
                  java.lang.String modTerm,
                  float rate,
                  boolean oja)
Sets learning parameters on learned terminations in the array.

Parameters:
learnTerm - name of the learned termination
modTerm - name of the modulatory termination
rate - learning rate
oja - whether or not to use Oja smoothing

setLearning

public void setLearning(boolean learn)
Sets learning on/off for all ensembles in the network.

Parameters:
learn - true if the ensembles are learning, else false

releaseMemory

public void releaseMemory()
Releases memory of all ensembles in the network.


getEncoders

public float[][] getEncoders()
Returns the encoders for the whole network array (the encoders of each population within the array concatenated together).

Returns:
encoders of each neuron in the network array

Nengo.ca