Class NeuronSquareMesh2D
- java.lang.Object
-
- org.apache.commons.math4.neuralnet.twod.NeuronSquareMesh2D
-
public class NeuronSquareMesh2D extends Object implements Iterable<Neuron>
Neural network with the topology of a two-dimensional surface. Each neuron defines one surface element.
This network is primarily intended to represent a Self Organizing Feature Map.- Since:
- 3.3
- See Also:
org.apache.commons.math4.neuralnet.sofm
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
NeuronSquareMesh2D.DataVisualization
Miscellaneous indicators of the map quality.static class
NeuronSquareMesh2D.HorizontalDirection
Horizontal (along row) direction.static class
NeuronSquareMesh2D.VerticalDirection
Vertical (along column) direction.
-
Constructor Summary
Constructors Constructor Description NeuronSquareMesh2D(boolean wrapRowDim, boolean wrapColDim, SquareNeighbourhood neighbourhoodType, double[][][] featuresList)
NeuronSquareMesh2D(int numRows, boolean wrapRowDim, int numCols, boolean wrapColDim, SquareNeighbourhood neighbourhoodType, FeatureInitializer[] featureInit)
Creates a two-dimensional network composed of square cells: Each neuron not located on the border of the mesh has four neurons linked to it.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description NeuronSquareMesh2D.DataVisualization
computeQualityIndicators(Iterable<double[]> data)
Computes variousindicators
of the quality of the representation of the givendata
by this map.NeuronSquareMesh2D
copy()
Performs a deep copy of this instance.Network
getNetwork()
Retrieves the underlying network.Neuron
getNeuron(int i, int j)
Retrieves the neuron at location(i, j)
in the map.Neuron
getNeuron(int row, int col, NeuronSquareMesh2D.HorizontalDirection alongRowDir, NeuronSquareMesh2D.VerticalDirection alongColDir)
Retrieves the requested neuron relative to the given(row, col)
position.int
getNumberOfColumns()
Gets the number of neurons in each column of this map.int
getNumberOfRows()
Gets the number of neurons in each row of this map.SquareNeighbourhood
getSquareNeighbourhood()
Indicates thetype of connectivity
between neurons.boolean
isWrappedColumn()
Indicates whether the map is wrapped along the second dimension.boolean
isWrappedRow()
Indicates whether the map is wrapped along the first dimension.Iterator<Neuron>
iterator()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Constructor Detail
-
NeuronSquareMesh2D
public NeuronSquareMesh2D(boolean wrapRowDim, boolean wrapColDim, SquareNeighbourhood neighbourhoodType, double[][][] featuresList)
- Parameters:
wrapRowDim
- Whether to wrap the first dimension (i.e the first and last neurons will be linked together).wrapColDim
- Whether to wrap the second dimension (i.e the first and last neurons will be linked together).neighbourhoodType
- Neighbourhood type.featuresList
- Arrays that will initialize the features sets of the network's neurons.- Throws:
IllegalArgumentException
- ifnumRows < 2
ornumCols < 2
.
-
NeuronSquareMesh2D
public NeuronSquareMesh2D(int numRows, boolean wrapRowDim, int numCols, boolean wrapColDim, SquareNeighbourhood neighbourhoodType, FeatureInitializer[] featureInit)
Creates a two-dimensional network composed of square cells: Each neuron not located on the border of the mesh has four neurons linked to it.
The links are bi-directional.
The topology of the network can also be a cylinder (if one of the dimensions is wrapped) or a torus (if both dimensions are wrapped).- Parameters:
numRows
- Number of neurons in the first dimension.wrapRowDim
- Whether to wrap the first dimension (i.e the first and last neurons will be linked together).numCols
- Number of neurons in the second dimension.wrapColDim
- Whether to wrap the second dimension (i.e the first and last neurons will be linked together).neighbourhoodType
- Neighbourhood type.featureInit
- Array of functions that will initialize the corresponding element of the features set of each newly created neuron. In particular, the size of this array defines the size of feature set.- Throws:
IllegalArgumentException
- ifnumRows < 2
ornumCols < 2
.
-
-
Method Detail
-
copy
public NeuronSquareMesh2D copy()
Performs a deep copy of this instance. Upon return, the copied and original instances will be independent: Updating one will not affect the other.- Returns:
- a new instance with the same state as this instance.
- Since:
- 3.6
-
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 theNetwork
topology may cause this class to become inconsistent.- Returns:
- the network.
-
getNumberOfRows
public int getNumberOfRows()
Gets the number of neurons in each row of this map.- Returns:
- the number of rows.
-
getNumberOfColumns
public int getNumberOfColumns()
Gets the number of neurons in each column of this map.- Returns:
- the number of column.
-
isWrappedRow
public boolean isWrappedRow()
Indicates whether the map is wrapped along the first dimension.- Returns:
true
if the last neuron of a row is linked to the first neuron of that row.
-
isWrappedColumn
public boolean isWrappedColumn()
Indicates whether the map is wrapped along the second dimension.- Returns:
true
if the last neuron of a column is linked to the first neuron of that column.
-
getSquareNeighbourhood
public SquareNeighbourhood getSquareNeighbourhood()
Indicates thetype of connectivity
between neurons.- Returns:
- the neighbourhood type.
-
getNeuron
public Neuron getNeuron(int i, int j)
Retrieves the neuron at location(i, j)
in the map. The neuron at position(0, 0)
is located at the upper-left corner of the map.- Parameters:
i
- Row index.j
- Column index.- Returns:
- the neuron at
(i, j)
. - Throws:
IllegalArgumentException
- ifi
orj
is out of range.- See Also:
getNeuron(int,int,HorizontalDirection,VerticalDirection)
-
getNeuron
public Neuron getNeuron(int row, int col, NeuronSquareMesh2D.HorizontalDirection alongRowDir, NeuronSquareMesh2D.VerticalDirection alongColDir)
Retrieves the requested neuron relative to the given(row, col)
position. The neuron at position(0, 0)
is located at the upper-left corner of the map.- Parameters:
row
- Row index.col
- Column index.alongRowDir
- Direction along the givenrow
(i.e. an offset will be added to the given column index.alongColDir
- Direction along the givencol
(i.e. an offset will be added to the given row index.- Returns:
- the neuron at the requested location, or
null
if the location is not on the map. - See Also:
getNeuron(int,int)
-
computeQualityIndicators
public NeuronSquareMesh2D.DataVisualization computeQualityIndicators(Iterable<double[]> data)
Computes variousindicators
of the quality of the representation of the givendata
by this map.- Parameters:
data
- Features.- Returns:
- a new instance holding quality indicators.
-
-