Class NeuronString
- java.lang.Object
-
- org.apache.commons.math3.ml.neuralnet.oned.NeuronString
-
- All Implemented Interfaces:
java.io.Serializable
public class NeuronString extends java.lang.Object implements java.io.SerializableNeural network with the topology of a one-dimensional line. Each neuron defines one point on the line.- Since:
- 3.3
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classNeuronString.SerializationProxySerialization.
-
Field Summary
Fields Modifier and Type Field Description private long[]identifiersMapping of the 1D coordinate to the neuron identifiers (attributed by thenetworkinstance).private NetworknetworkUnderlying network.private static longserialVersionUIDSerial version IDprivate intsizeNumber of neurons.private booleanwrapWrap.
-
Constructor Summary
Constructors Constructor Description NeuronString(boolean wrap, double[][] featuresList)Constructor with restricted access, solely used for deserialization.NeuronString(int num, boolean wrap, FeatureInitializer[] featureInit)Creates a one-dimensional network: Each neuron not located on the border of the mesh has two neurons linked to it.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidcreateLinks()Creates the neighbour relationships between neurons.double[]getFeatures(int i)Retrieves the features set from the neuron at locationiin the map.NetworkgetNetwork()Retrieves the underlying network.intgetSize()Gets the number of neurons.private voidreadObject(java.io.ObjectInputStream in)Prevents proxy bypass.private java.lang.ObjectwriteReplace()Custom serialization.
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
Serial version ID- See Also:
- Constant Field Values
-
network
private final Network network
Underlying network.
-
size
private final int size
Number of neurons.
-
wrap
private final boolean wrap
Wrap.
-
identifiers
private final long[] identifiers
Mapping of the 1D coordinate to the neuron identifiers (attributed by thenetworkinstance).
-
-
Constructor Detail
-
NeuronString
NeuronString(boolean wrap, double[][] featuresList)Constructor with restricted access, solely used for deserialization.- Parameters:
wrap- Whether to wrap the dimension (i.e the first and last neurons will be linked together).featuresList- Arrays that will initialize the features sets of the network's neurons.- Throws:
NumberIsTooSmallException- ifnum < 2.
-
NeuronString
public NeuronString(int num, boolean wrap, FeatureInitializer[] featureInit)Creates a one-dimensional network: Each neuron not located on the border of the mesh has two neurons linked to it.
The links are bi-directional. Neurons created successively are neighbours (i.e. there are links between them).
The topology of the network can also be a circle (if the dimension is wrapped).- Parameters:
num- Number of neurons.wrap- Whether to wrap the dimension (i.e the first and last neurons will be linked together).featureInit- Arrays that will initialize the features sets of the network's neurons.- Throws:
NumberIsTooSmallException- ifnum < 2.
-
-
Method Detail
-
getNetwork
public Network getNetwork()
Retrieves the underlying network. A reference is returned (enabling, for example, the network to be trained). This also implies that calling methods that modify theNetworktopology may cause this class to become inconsistent.- Returns:
- the network.
-
getSize
public int getSize()
Gets the number of neurons.- Returns:
- the number of neurons.
-
getFeatures
public double[] getFeatures(int i)
Retrieves the features set from the neuron at locationiin the map.- Parameters:
i- Neuron index.- Returns:
- the features of the neuron at index
i. - Throws:
OutOfRangeException- ifiis out of range.
-
createLinks
private void createLinks()
Creates the neighbour relationships between neurons.
-
readObject
private void readObject(java.io.ObjectInputStream in)
Prevents proxy bypass.- Parameters:
in- Input stream.
-
writeReplace
private java.lang.Object writeReplace()
Custom serialization.- Returns:
- the proxy instance that will be actually serialized.
-
-