public class NeuronGroup extends Group implements CopyableGroup<NeuronGroup>
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_GROUP_SIZE
The number of neurons in the group by default.
|
static Layout |
DEFAULT_LAYOUT
Default layout for neuron groups.
|
static int |
FLUSH_FREQUENCY
The default for how often
writeActsToFile() should flush
the output stream when writing to a file. |
Constructor and Description |
---|
NeuronGroup(Network network)
Create a neuron group without any initial neurons.
|
NeuronGroup(Network net,
int numNeurons)
Construct a new neuron group with a specified number of neurons.
|
NeuronGroup(Network net,
java.util.List<Neuron> neurons)
Construct a new neuron group from a list of neurons.
|
NeuronGroup(Network network,
NeuronGroup toCopy)
Copy constructor.
|
NeuronGroup(Network network,
java.awt.geom.Point2D initialPosition)
Create a neuron group without any initial neurons and an initial
position.
|
NeuronGroup(Network net,
java.awt.geom.Point2D initialPosition,
int numNeurons)
Construct a new neuron group with a specified number of neurons.
|
Modifier and Type | Method and Description |
---|---|
void |
addIncomingSg(SynapseGroup sg) |
void |
addNeuron(Neuron neuron)
Add neuron to group.
|
void |
addNeuron(Neuron neuron,
boolean fireEvent)
Add a neuron to group.
|
void |
addOutgoingSg(SynapseGroup sg) |
void |
applyInputs()
Apply any input values to the activations of the neurons in this group.
|
void |
applyLayout()
Apply this group's layout to its neurons.
|
void |
applyLayout(java.awt.geom.Point2D initialPosition)
Apply this group's layout to its neurons based on a specified initial
position.
|
void |
clearActivations()
Set all activations to 0.
|
void |
clearNeuronList()
Clear the neuron list.
|
boolean |
containsAsIncoming(SynapseGroup sg) |
boolean |
containsAsOutgoing(SynapseGroup sg) |
boolean |
containsNeuron(Neuron n)
True if the group contains the specified neuron.
|
void |
copyActivations(NeuronGroup toCopy)
Copy activations from one neuron group to this one.
|
NeuronGroup |
deepCopy(Network newParent)
Returns a deep copy of a copyable group using the same root network as
the original.
|
void |
delete()
Perform necessary deletion cleanup.
|
void |
forceSetActivationLevels(double value)
Force set all activations to a specified value.
|
void |
forceSetActivations(double[] inputs)
Force set activations of neurons using an array of doubles.
|
double[] |
getActivations()
Return activations as a double array.
|
int |
getBetweenNeuronInterval() |
double[] |
getBiases()
Return biases as a double array.
|
double |
getCenterX()
Get the central x coordinate of this group, based on the positions of the
neurons that comprise it.
|
double |
getCenterY()
Get the central y coordinate of this group, based on the positions of the
neurons that comprise it.
|
double[] |
getExternalActivations()
Returns a vector of activations to be used by some object external to the
neuron group.
|
java.awt.geom.Point2D[] |
getFourCorners() |
int |
getGridThreshold() |
double |
getHeight()
Return the height of this group, based on the positions of the neurons
that comprise it.
|
java.util.HashSet<SynapseGroup> |
getIncomingSgs() |
java.util.List<Synapse> |
getIncomingWeights()
Return flat list of fanins for all neurons in group.
|
java.lang.String |
getLabelsOfActiveNeurons(double threshold)
Utility to method (used in couplings) to get a string showing the labels
of all "active" neurons (neurons with activation above a threshold).
|
Layout |
getLayout() |
double |
getMaxDim() |
double |
getMaxX()
Returns the maximum X position of this group based on the neurons that
comprise it.
|
double |
getMaxY()
Returns the maximum Y position of this group based on the neurons that
comprise it.
|
double |
getMinX()
Returns the minimum X position of this group based on the neurons that
comprise it.
|
double |
getMinY()
Returns the minimum Y position of this group based on the neurons that
comprise it.
|
java.lang.String |
getMostActiveNeuron()
Returns the label of the most active neuron.
|
java.util.List<Neuron> |
getNeuronList() |
java.util.List<Neuron> |
getNeuronsInRadius(Neuron n,
int radius)
Returns all the neurons in this group within a certain radius of the
given neuron.
|
java.lang.String |
getNeuronType() |
static int |
getNumSubSamples() |
java.util.HashSet<SynapseGroup> |
getOutgoingSg() |
java.util.List<Synapse> |
getOutgoingWeights()
Return flat list of fanouts for all neurons in group.
|
java.awt.geom.Point2D.Double |
getPosition()
Return current position (upper left corner of neuron in the farthest
north-west position.
|
double[] |
getSpikeIndexes()
Returns an array of spike indices used in couplings, (e.g.
|
double[][] |
getTestData() |
java.lang.String |
getTypeDescription()
Return a human-readable name for this type of neuron group.
|
java.lang.String |
getUpdateMethodDesecription()
Returns a description of this group's update method, which is displayed
in the update manager panel.
|
double |
getWidth()
Return the width of this group, based on the positions of the neurons
that comprise it.
|
boolean |
inFanInOfSomeNode(Synapse synapse)
Returns true if the provided synapse is in the fan-in weight vector of
some node in this neuron group.
|
boolean |
isAllClamped()
Returns true if all the neurons in this group are clamped.
|
boolean |
isAllUnclamped()
Returns true if all the neurons in this group are unclamped.
|
boolean |
isEmpty()
Whether this group is empty or not.
|
boolean |
isInputMode() |
boolean |
isRecordAsSpikes() |
boolean |
isRecording() |
boolean |
isSpikingNeuronGroup() |
static boolean |
isUseSubSampling() |
void |
offset(double offsetX,
double offsetY)
Translate all neurons (the only objects with position information).
|
void |
printActivations()
Print activations as a vector.
|
void |
prune()
Removes all neurons with no incoming or outgoing synapses from the group.
|
void |
randomize()
Randomize all neurons in group.
|
void |
randomizeBiases(double lower,
double upper)
Randomize bias for all neurons in group.
|
void |
randomizeIncomingWeights()
Randomize fan-in for all neurons in group.
|
void |
randomizeOutgoingWeights()
Randomize fan-out for all neurons in group.
|
void |
readNextInputs()
A forwarding method surrounding
readNextInputUnsafe() in the
appropriate checks to make it safe. |
boolean |
removeIncomingSg(SynapseGroup sg) |
void |
removeNeuron(Neuron toDelete)
Delete the provided neuron.
|
boolean |
removeOutgoingSg(SynapseGroup sg) |
void |
resetSubsamplingIndices()
Reset the indices used for subsampling
|
void |
setActivationLevels(double value)
Set all activations to a specified value.
|
void |
setActivations(double[] inputs)
Set activations of neurons using an array of doubles.
|
void |
setBetweenNeuronInterval(int betweenNeuronInterval) |
void |
setClamped(boolean clamp)
Set clamping on all neurons in this group.
|
void |
setGridThreshold(int gridThreshold) |
void |
setIncrement(double increment)
Set the increment on all neurons in this group.
|
void |
setInputMode(boolean inputMode)
Sets whether or not this neuron group is in input mode.
|
void |
setInputValues(double[] inputs)
Set input values of neurons using an array of doubles.
|
void |
setLayout(Layout layout)
Set the layout.
|
void |
setLayoutBasedOnSize()
If more than gridThreshold neurons use a grid layout, else a horizontal
line layout.
|
void |
setLayoutBasedOnSize(java.awt.geom.Point2D initialPosition)
If more than gridThreshold neurons use a grid layout, else a horizontal
line layout.
|
void |
setLocation(double x,
double y) |
void |
setLowerBound(double lb)
Set the lower bound on all neurons in this group.
|
void |
setNeuronType(NeuronUpdateRule base)
Set the update rule for the neurons in this group.
|
void |
setNeuronType(java.lang.String rule)
Set the string update rule for the neurons in this group.
|
static void |
setNumSubSamples(int numSubSamples) |
void |
setRecordAsSpikes(boolean recordAsSpikes) |
void |
setSpikingNeuronGroup(boolean isSpikingNeuronGroup) |
void |
setTestData(double[][] testData) |
void |
setUpperBound(double ub)
Set the upper bound on all neurons in this group.
|
static void |
setUseSubSampling(boolean useSubSampling) |
void |
setXYZCoordinatesFromFile(java.lang.String filename) |
int |
size() |
void |
startRecording(java.io.File outputFile)
Creates a file which activations will be written to and activates the
necessary output streams.
|
void |
stopRecording()
Halts recording of activations.
|
void |
testAndSetIfSpiking()
Tests if this neuron group can be considered a spiking neuron group
and sets that value to true/false acordingly.
|
java.lang.String |
toString() |
void |
update()
Updates all the neurons in the neuron group according to their
NeuronUpdateRule(s).
|
void |
writeActsToFile()
Writes the activations of the network to a file.
|
getId, getLabel, getParentGroup, getParentNetwork, getStateInfo, hasParentGroup, isMarkedForDeletion, isTopLevelGroup, recursivelySetIds, setId, setLabel, setMarkedForDeletion, setParentGroup, setStateInfo
public static final int FLUSH_FREQUENCY
writeActsToFile()
should flush
the output stream when writing to a file.public static final int DEFAULT_GROUP_SIZE
public static final Layout DEFAULT_LAYOUT
public NeuronGroup(Network net, java.util.List<Neuron> neurons)
net
- the networkneurons
- the neuronspublic NeuronGroup(Network net, int numNeurons)
net
- parent networknumNeurons
- how many neurons it will havepublic NeuronGroup(Network net, java.awt.geom.Point2D initialPosition, int numNeurons)
net
- parent networkinitialPosition
- initial location of the groupnumNeurons
- how many neurons it will havepublic NeuronGroup(Network network, java.awt.geom.Point2D initialPosition)
network
- parent networkinitialPosition
- the starting position from which to lay-out the neurons in the
group whenever they are added.public NeuronGroup(Network network)
network
- parent networkpublic NeuronGroup(Network network, NeuronGroup toCopy)
network
- parent networktoCopy
- the neuron group this will become a (deep) copy of.public void resetSubsamplingIndices()
public NeuronGroup deepCopy(Network newParent)
CopyableGroup
deepCopy
in interface CopyableGroup<NeuronGroup>
newParent
- the parent network for this group, potentially
different from the original (used when copying and pasting
from one network to another)public void delete()
Group
public void update()
public void readNextInputs()
readNextInputUnsafe()
in the
appropriate checks to make it safe. This allows outside classes to
force the neuron group to read in and set activations according to
the value(s) in its input table.public void startRecording(java.io.File outputFile)
recordAsSpikes
to true, since writeActsToFile()
writes
activations differently if the neuron group contains only spiking
neurons.outputFile
- the file to write the activations topublic void stopRecording()
public void writeActsToFile()
#startRecording()
is called, the group checks whether or not the
group is entirely populated by spiking neurons. If it is then this
methods writes the activations to a file as spike trains in [neuron
id][spk time] couplets. Otherwise it writes the neurons' activation
values as a state matrix to the file. Flushes the output stream every
FLUSH_FREQUENCY
invocations.public java.lang.String getNeuronType()
public java.util.List<Neuron> getNeuronList()
public void setNeuronType(NeuronUpdateRule base)
base
- the neuron update rule to set.public void setNeuronType(java.lang.String rule)
rule
- the neuron update rule to set.public java.lang.String getTypeDescription()
public boolean inFanInOfSomeNode(Synapse synapse)
synapse
- the synapse to checkpublic void randomizeIncomingWeights()
public void randomizeOutgoingWeights()
public java.util.List<Synapse> getIncomingWeights()
public java.util.List<Synapse> getOutgoingWeights()
public void randomize()
public void randomizeBiases(double lower, double upper)
lower
- lower bound for randomization.upper
- upper bound for randomization.public void addNeuron(Neuron neuron, boolean fireEvent)
neuron
- neuron to addfireEvent
- whether to fire a neuron added eventpublic void addNeuron(Neuron neuron)
neuron
- neuron to addpublic void removeNeuron(Neuron toDelete)
toDelete
- the neuron to deletepublic void prune()
public boolean isEmpty()
Group
public void setInputValues(double[] inputs)
inputs
- the input vector as a double array.public void setActivations(double[] inputs)
inputs
- the input vector as a double array.public void forceSetActivations(double[] inputs)
inputs
- the input vector as a double array.public double[] getActivations()
public double[] getSpikeIndexes()
public double[] getBiases()
public boolean containsNeuron(Neuron n)
n
- neuron to check for.public int size()
public java.util.List<Neuron> getNeuronsInRadius(Neuron n, int radius)
n
- the neuronsradius
- the radius to search within.public double getCenterX()
public double getCenterY()
public double getMaxX()
public double getMinX()
public double getMaxY()
public double getMinY()
public double getWidth()
public double getHeight()
public double getMaxDim()
public java.awt.geom.Point2D[] getFourCorners()
public void setLocation(double x, double y)
x
- x coordinate for neuron groupy
- y coordinate for neuron grouppublic void offset(double offsetX, double offsetY)
offsetX
- x offset for translation.offsetY
- y offset for translation.public void clearActivations()
public void setClamped(boolean clamp)
clamp
- true to clamp them, false otherwisepublic void setActivationLevels(double value)
value
- the value to set the neurons topublic void forceSetActivationLevels(double value)
value
- the value to set the neurons topublic void copyActivations(NeuronGroup toCopy)
toCopy
- the group to copy activations from.public void printActivations()
public java.lang.String getUpdateMethodDesecription()
Group
getUpdateMethodDesecription
in class Group
public void applyInputs()
public Layout getLayout()
public void setLayout(Layout layout)
layout
- the layout to setpublic java.awt.geom.Point2D.Double getPosition()
public void setXYZCoordinatesFromFile(java.lang.String filename)
public void applyLayout()
public void applyLayout(java.awt.geom.Point2D initialPosition)
initialPosition
- the position from which to begin the layout.public java.util.HashSet<SynapseGroup> getIncomingSgs()
public java.util.HashSet<SynapseGroup> getOutgoingSg()
public boolean containsAsIncoming(SynapseGroup sg)
public boolean containsAsOutgoing(SynapseGroup sg)
public void addIncomingSg(SynapseGroup sg)
public void addOutgoingSg(SynapseGroup sg)
public boolean removeIncomingSg(SynapseGroup sg)
public boolean removeOutgoingSg(SynapseGroup sg)
public boolean isAllClamped()
public boolean isAllUnclamped()
public void setLowerBound(double lb)
lb
- the lower bound to set.public void setUpperBound(double ub)
ub
- the upper bound to set.public void setIncrement(double increment)
increment
- the increment to set.public double[][] getTestData()
public void setTestData(double[][] testData) throws java.lang.IllegalArgumentException
testData
- the testData to setjava.lang.IllegalArgumentException
public void testAndSetIfSpiking()
public void setLayoutBasedOnSize()
public void setLayoutBasedOnSize(java.awt.geom.Point2D initialPosition)
initialPosition
- the initial Position for the layoutpublic int getBetweenNeuronInterval()
public void setBetweenNeuronInterval(int betweenNeuronInterval)
betweenNeuronInterval
- the betweenNeuronInterval to setpublic int getGridThreshold()
public void setGridThreshold(int gridThreshold)
gridThreshold
- the gridThreshold to setpublic void clearNeuronList()
public java.lang.String getLabelsOfActiveNeurons(double threshold)
threshold
- threshold above which to consider a neuron "active"public java.lang.String getMostActiveNeuron()
public boolean isRecording()
public void setRecordAsSpikes(boolean recordAsSpikes)
public boolean isRecordAsSpikes()
public boolean isInputMode()
public void setInputMode(boolean inputMode) throws java.lang.IllegalArgumentException
testData
field instead of from any impinging synapses or its own neuron update
functions. This function removes the neurons from the neuron set in
ConcurrentBufferedUpdate, preventing it from updating the neurons in
this group, and re-adds those neurons when input mode is turned off.
Thus the update action associated with this neuron group MUST be added
to the network update sequence even if ParallelBufferedUpdate is
selected in order for input values to update the group properly.inputMode
- whether or not this group will run in input mode during
network and workspace updates.java.lang.IllegalArgumentException
- if input mode is set to true, but the
testData
field is set to null.public boolean isSpikingNeuronGroup()
public void setSpikingNeuronGroup(boolean isSpikingNeuronGroup)
public double[] getExternalActivations()
public static boolean isUseSubSampling()
public static void setUseSubSampling(boolean useSubSampling)
useSubSampling
- the useSubSampling to setpublic static int getNumSubSamples()
public static void setNumSubSamples(int numSubSamples)
numSubSamples
- the numSubSamples to set