public class GrowingLayer extends java.lang.Object implements Layer
Modifier and Type | Class and Description |
---|---|
static class |
GrowingLayer.Flip |
static class |
GrowingLayer.Rotation |
(package private) class |
GrowingLayer.UpdaterThread |
Layer.GridLayout, Layer.GridTopology
Modifier and Type | Field and Description |
---|---|
private java.util.Hashtable<java.lang.Integer,java.awt.geom.Point2D[][]> |
binAssignmentCache |
private java.lang.String |
commonVectorLabelPrefix |
private static double |
CUTOFF_SIGMA |
private InputData |
data |
protected int |
dim |
private java.util.concurrent.CountDownLatch |
doneSignal |
private java.util.concurrent.ExecutorService |
e |
protected Layer.GridLayout |
gridLayout |
protected Layer.GridTopology |
gridTopology |
private int |
identifier |
private int |
interruptEvery |
private int |
level |
(package private) double[] |
maxFeatureValues |
private int |
maximumNumberOfMappedInputs |
protected DistanceMetric |
metric |
private java.lang.String |
metricName |
protected AbstractWeightedMetric |
metricWeighted |
(package private) double[] |
minFeatureValues |
private boolean |
normalized |
private int |
notEmptyUnits
Stores the number of units that are not empty, i.e.
|
private QualityMeasure |
qualityMeasure |
private java.util.Random |
rand |
private java.util.Random |
randSkipProbability |
private Cuboid[] |
ranges |
private java.util.Hashtable<java.lang.Integer,java.util.ArrayList<ComponentRegionCount>> |
regionAssignmentCache |
private java.lang.String |
revision |
static int[] |
ROTATIONS |
(package private) int |
skippedNonSelected |
private Unit |
superUnit |
private static int |
THREAD_COUNT |
private int |
threadsUsed |
private TrainingInterruptionListener |
til |
(package private) int |
trainedNonSelected |
cern.colt.matrix.DoubleMatrix2D |
unitDistanceMatrix |
private java.lang.String |
unitPath |
protected Unit[][][] |
units |
private AdaptiveCoordinatesVirtualLayer |
virtualLayer |
protected int |
xSize |
protected int |
ySize |
protected int |
zSize |
Constructor and Description |
---|
GrowingLayer(int xSize,
int ySize,
int zSize,
java.lang.String metricName,
int dim,
boolean normalized,
boolean usePCA,
long seed,
InputData data)
Convenience constructor for top layer map of GHSOM or a single map.
|
GrowingLayer(int xSize,
int ySize,
java.lang.String metricName,
int dim,
boolean normalized,
boolean usePCA,
long seed,
InputData data)
Convenience constructor for top layer map of GHSOM or a single map.
|
GrowingLayer(int id,
Unit su,
int xSize,
int ySize,
int zSize,
java.lang.String metricName,
int dim,
boolean normalized,
boolean usePCA,
long seed,
InputData data)
Constructor for a new, untrained layer.
|
GrowingLayer(int id,
Unit su,
int xSize,
int ySize,
int zSize,
java.lang.String metricName,
int dim,
double[][][][] vectors,
long seed)
Constructor for an already trained layer as specified by 2-dimensional array of d-dimensional weight vectors as
argument
vectors . |
GrowingLayer(int id,
Unit su,
int xSize,
int ySize,
java.lang.String metricName,
int dim,
boolean normalized,
boolean usePCA,
long seed,
InputData data)
Constructor for a new, untrained layer.
|
GrowingLayer(int id,
Unit su,
int xSize,
int ySize,
java.lang.String metricName,
int dim,
double[][][] vectors,
long seed)
Constructor for an already trained layer as specified by 2-dimensional array of d-dimensional weight vectors as
argument
vectors . |
Modifier and Type | Method and Description |
---|---|
protected static double[][][][] |
addDimension(int x,
int y,
double[][][] vec) |
void |
calculateQuantizationErrorForUnits()
Calculates the quantization error for all units of the layer.
|
static void |
checkRotation(int rotation) |
void |
clearLabels()
Removes all labels from the units.
|
void |
clearMappedInput()
Removes all mapped input data from the units.
|
java.lang.Object |
clone()
Clone might not be fully functional!
|
InputCorrections |
computeUnitFeatureWeights(InputCorrections corrections,
InputData data,
Unit.FeatureWeightMode mode)
Implementation of general weighting as in Nünrberger/Detyniecki, 'Weighted Self-Organizing Maps: Incorporating
User Feedback'
|
boolean |
equalWeights(GrowingLayer otherLayer)
Checks whether this and the given
GrowingLayer are equal in their weight (model) vectors. |
void |
flip(GrowingLayer.Flip flip)
Flip the layer.
|
Unit[][] |
get2DUnits()
Returns all units with depth 0 of the layer
|
java.lang.String[] |
getAllMappedDataNames() |
java.lang.String[] |
getAllMappedDataNames(boolean sort)
Returns all mapped inputs from all the units of the layer in an array.
|
java.util.ArrayList<java.lang.String> |
getAllMappedDataNamesAsList() |
java.util.ArrayList<GrowingSOM> |
getAllSubMaps() |
Unit[] |
getAllUnits()
Returns all units of the layer in an array.
|
int[][] |
getBinAssignment(int component,
int bins) |
java.awt.geom.Point2D[][] |
getBinCentres(int bins) |
java.awt.geom.Point2D[] |
getBinCentres(int[][] binAssignment,
int bins) |
java.util.ArrayList<ComponentLine2D> |
getBinCentresAsList(int bins) |
double |
getBinDeviation(int[][] binAssignment,
int bins) |
java.lang.String |
getCommonVectorLabelPrefix() |
double[][] |
getComponentPlane(int component)
Returns a component plane of the component specified by the argument
component . |
double[][] |
getComponentPlane(int component,
int z)
Returns a component plane of the component specified by the argument
component . |
double[][][] |
getComponentPlane3D(int component) |
InputData |
getData() |
double[] |
getDeviation(int bins) |
int |
getDim()
Returns the dimensionality of the weight vectors.
|
private int |
getDimension(int x,
int y,
int z,
double[][][][] vectors)
Needed for mnemonic (sparse) SOMs to find out the vector dimension, by finding the first non-null vector in the
array
|
private Unit |
getErrorUnit(QualityMeasure qm,
java.lang.String methodName)
Returns the unit having the highest quantization error.
|
double[][] |
getExtremes() |
private java.lang.String[] |
getFirstNLabels(int n,
java.util.ArrayList<InputNameDistance> items) |
Layer.GridLayout |
getGridLayout() |
Layer.GridTopology |
getGridTopology() |
java.lang.String |
getIdString()
Returns the identification string of the map layer.
|
private double[] |
getInputVector(java.lang.String query,
SOMLibTemplateVector templateVector) |
int |
getLevel()
Returns the level of the map layer in a hierarchical model.
|
double |
getMapDistance(int x1,
int y1,
int x2,
int y2) |
double |
getMapDistance(int x1,
int y1,
int z1,
int x2,
int y2,
int z2)
Returns the distance between two units on the map grid.
|
double |
getMapDistance(Unit u1,
Unit u2)
Returns the distance between two units on the map grid.
|
double |
getMapDistanceSq(int x1,
int y1,
int z1,
int x2,
int y2,
int z2) |
double |
getMapDistanceSq(Unit u1,
Unit u2) |
int |
getMaximumNumberOfMappedInputs()
Calculates and returns the maximum number of items mapped to a unit in this layer
|
DistanceMetric |
getMetric()
Calculates and returns the mean quantization error of the map based on the quantization errors of the single
units.
|
protected Unit |
getMostDissimilarNeighbor(Unit u)
Returns the neighboring unit of a unit specified by argument
u with the most distant weight vector. |
java.util.ArrayList<Unit> |
getNeighbouringUnits(int x,
int y) |
java.util.ArrayList<Unit> |
getNeighbouringUnits(int x,
int y,
double radius)
Convenience method for
getNeighbouringUnits(int, int, int, double) |
private java.util.ArrayList<Unit> |
getNeighbouringUnits(int x,
int y,
int z) |
java.util.ArrayList<Unit> |
getNeighbouringUnits(int x,
int y,
int z,
double radius)
Gets neighbours within a certain radius; uses
getMapDistance(int, int, int, int, int, int) for map
distance computation |
protected java.util.ArrayList<Unit> |
getNeighbouringUnits(Unit u)
Get direct neighbours of the given unit.
|
protected java.util.ArrayList<Unit> |
getNeighbouringUnits(Unit u,
double radius)
Convenience method for
getNeighbouringUnits(int, int, int, double) |
java.lang.String[] |
getNNearestInputs(java.lang.String datumlabel,
int n,
InputData data) |
java.lang.String[] |
getNNearestInputs(Unit u,
int n) |
static int |
getNO_CPUS() |
int |
getNumberOfMappedInputs()
Returns the total number of Inputs mapped on all units in the map layer.
|
int |
getNumberOfNotEmptyUnits()
Calculates and returns the number of units that are not empty, i.e.
|
java.util.ArrayList<ComponentRegionCount> |
getNumberOfRegions(int bins) |
private int |
getNumberOfRegions(int[][] regionAssignement) |
QualityMeasure |
getQualityMeasure()
Returns the quality information.
|
private int[][] |
getRegionAssignement(int[][] binAssignement,
int numberOfBins) |
java.lang.String |
getRevision()
Returns the revision string of this layer.
|
Unit |
getSuperUnit()
Returns the superordinate unit, or
null if none exists. |
Unit |
getUnit(int x,
int y)
Returns the
Unit at the position specified by the x and y arguments. |
Unit |
getUnit(int x,
int y,
int z)
Returns the
Unit at the position specified by the x and y arguments. |
int |
getUnitCount() |
cern.colt.matrix.DoubleMatrix2D |
getUnitDistanceMatrix()
|
Unit |
getUnitForDatum(java.lang.String name)
Returns the unit onto which the datum specified by its name by argument
name is mapped. |
Unit |
getUnitForIndex(int index) |
int |
getUnitIndex(int x,
int y)
Returns the index of given unit coordinates.
|
java.lang.String |
getUnitPath() |
Unit[][][] |
getUnits()
Returns all units of the layer in a 3D array.
|
AdaptiveCoordinatesVirtualLayer |
getVirtualLayer() |
Unit |
getWinner(InputDatum input)
Returns the winner unit for a given input datum specified by argument
input . |
Unit |
getWinner(InputDatum input,
AbstractWeightedMetric metric)
Returns the winner for a given unit, using a weighted distance metric.
|
Unit |
getWinner(InputDatum input,
DistanceMetric metric)
Returns the winner unit for a given input datum specified by argument
input . |
Unit |
getWinnerFromQuery(java.lang.String query,
SOMLibTemplateVector templateVector)
Return the winning unit for the given query.
|
Unit[] |
getWinners(InputDatum input,
int num) |
Unit[] |
getWinners(InputDatum input,
int num,
DistanceMetric metric)
Returns a number of best-matching units sorted by distance (ascending) for a given input datum.
|
UnitDistance[] |
getWinnersAndDistances(InputDatum input,
int num)
Returns a number of best-matching units and distances sorted by distance (ascending) for a given input datum.
|
Unit[] |
getWinnersFromQuery(java.lang.String query,
int num,
SOMLibTemplateVector templateVector) |
java.lang.String[] |
getWinningInputDataFromQuery(java.lang.String query,
int num,
SOMLibTemplateVector templateVector) |
int |
getXSize()
Returns the width of the map layer.
|
int |
getYSize()
Returns the height of the map layer.
|
int |
getZSize()
Returns the depth of the map layer.
|
boolean |
hasMappedInput(int x,
int y) |
boolean |
hasNeighbours(int x,
int y) |
boolean |
hasNeighbours(int x,
int y,
int z) |
private void |
initCPURanges() |
private void |
initSuperUnit(int id,
Unit su) |
private void |
insertRowColumn(Unit a,
Unit b,
ProgressListener listener)
Inserts a row or column of units between units specified by argument
a and b . |
boolean |
isEdgeColumn(int x) |
boolean |
isEdgeRow(int y) |
boolean |
isValidUnitLocation(int x,
int y) |
boolean |
isValidUnitLocation(java.awt.Point pos) |
private void |
mapCompleteDataAfterTraining(InputData data)
Maps data onto layer without recalculating the quantization error after every single input datum.
FIXME: add multi-threading |
void |
mapData(InputData data)
Maps input data onto layer.
|
Unit |
mapDatum(InputDatum datum)
Maps a single input datum onto the layer and returns the winning unit.
|
double |
maxNeighbourhoodRadius()
Computes the maximum value the neighbourhood radius can take, that is in the diagonal from one corner to the
other.
|
double |
neighbourhoodFeatureWeight(double dist,
int maxDist) |
private void |
printInfo(double targetQualityValue,
java.lang.String[] qmNameMethod,
QualityMeasure qm) |
java.lang.String |
printSize() |
java.lang.String |
printUnitIndices() |
private void |
processRegionRecursive(int[][] binAssignment,
int[][] regionAssignment,
int x,
int y) |
void |
rotate(GrowingLayer.Rotation rotation)
Clockwise rotate the layer by the given degrees.
|
void |
rotate(int rotation) |
void |
setCommonVectorLabelPrefix(java.lang.String commonVectorLabelPrefix) |
void |
setGridLayout(Layer.GridLayout gridLayout) |
void |
setGridTopology(Layer.GridTopology gridTopology) |
static void |
setNO_CPUS(int no_cpus) |
void |
setQualityMeasure(java.lang.String qualityMeasureName) |
void |
setTrainingInterruptionListener(TrainingInterruptionListener t,
int i)
Assigns an object that implements the
TrainingInterruptionListener interface to perform actions in
certain intervals during training determined by argument i . |
private boolean |
specialClassMode(SOMProperties trainingProps) |
QualityMeasure |
train(InputData data,
double initialLearnrate,
double initialSigma,
int numIterations,
double tau,
double targetQualityValue,
java.lang.String qualityMeasureName,
SOMProperties trainingProps)
Trains the layer with the input data.
|
QualityMeasure |
train(InputData data,
double iniLearnrate,
double iniSigma,
int numIterations,
double tau,
java.lang.String qualityMeasureName,
SOMProperties trainingProps)
Trains the layer with the input data.
|
QualityMeasure |
train(InputData data,
double initialLearnrate,
double initialSigma,
int numIterations,
int startIteration,
double tau,
double targetQualityValue,
java.lang.String qualityMeasureName,
SOMProperties trainingProps)
Trains the layer with the input data.
|
QualityMeasure |
train(InputData data,
double iniLearnrate,
double iniSigma,
int numIterations,
int startIteration,
double tau,
java.lang.String qualityMeasureName,
SOMProperties trainingProps)
Trains the layer with the input data.
|
private void |
trainNormal(InputData data,
int numIterations,
int startIteration,
SOMProperties trainingProps,
double initialLearnrate,
double initialSigma,
double expParam,
double expParam2,
ProgressListener progressWriter) |
private void |
trainSpecial(InputData data,
int numIterations,
int startIteration,
SOMProperties trainingProps,
double initialLearnrate,
double initialSigma,
double expParam,
double expParam2,
SOMLibClassInformation classInfo,
double minProbability,
ProgressListener progressWriter) |
private void |
updateUnits(Unit winner,
InputDatum input,
double learnrate,
double sigma) |
private void |
updateUnitsInArea(Unit winner,
double learnrate,
double opt1,
double[] inputVector,
Cuboid range) |
private void |
updateUnitsInArea(Unit winner,
double learnrate,
double opt1,
double[] inputVector,
int startX,
int endX,
int startY,
int endY,
int startZ,
int endZ) |
private void |
updateUnitsNoBorder(Unit winner,
InputDatum input,
double learnrate,
double sigma)
Updates the weight vectors of the all map units with respect to the input datum and the according winner unit.
|
protected void |
updateUnitsNormal(Unit winner,
InputDatum input,
double learnrate,
double sigma)
Updates the weight vectors of the all map units with respect to the input datum and the according winner unit.
|
private static final double CUTOFF_SIGMA
public static final int[] ROTATIONS
protected int dim
private int identifier
private java.lang.String unitPath
private int interruptEvery
private int level
protected DistanceMetric metric
protected AbstractWeightedMetric metricWeighted
private java.lang.String metricName
private boolean normalized
private QualityMeasure qualityMeasure
private java.util.Random rand
private java.util.Random randSkipProbability
private final java.lang.String revision
private Unit superUnit
private TrainingInterruptionListener til
protected Unit[][][] units
protected int xSize
protected int ySize
protected int zSize
double[] minFeatureValues
double[] maxFeatureValues
protected Layer.GridLayout gridLayout
protected Layer.GridTopology gridTopology
private java.util.Hashtable<java.lang.Integer,java.awt.geom.Point2D[][]> binAssignmentCache
private java.util.Hashtable<java.lang.Integer,java.util.ArrayList<ComponentRegionCount>> regionAssignmentCache
private static int THREAD_COUNT
private java.util.concurrent.CountDownLatch doneSignal
private java.util.concurrent.ExecutorService e
private Cuboid[] ranges
private final int threadsUsed
private int notEmptyUnits
getNumberOfNotEmptyUnits()
, as the calculation of the value is only
performed by that method and stored for future access.private InputData data
int skippedNonSelected
int trainedNonSelected
private java.lang.String commonVectorLabelPrefix
public cern.colt.matrix.DoubleMatrix2D unitDistanceMatrix
private AdaptiveCoordinatesVirtualLayer virtualLayer
private int maximumNumberOfMappedInputs
public GrowingLayer(int xSize, int ySize, java.lang.String metricName, int dim, boolean normalized, boolean usePCA, long seed, InputData data)
null
.xSize
- the number of columns.ySize
- the number of rows.metricName
- the name of the distance metric to use.dim
- the dimensionality of the weight vectors.normalized
- the type of normalization that is applied to the weight vectors of newly created units. This is
usually Normalization.NONE
or Normalization.UNIT_LEN
.seed
- the random seed for creation of the units' weight vectors.public GrowingLayer(int xSize, int ySize, int zSize, java.lang.String metricName, int dim, boolean normalized, boolean usePCA, long seed, InputData data)
null
.xSize
- the number of columns.ySize
- the number of rows.zSize
- the depthmetricName
- the name of the distance metric to use.dim
- the dimensionality of the weight vectors.normalized
- the type of normalization that is applied to the weight vectors of newly created units. This is
usually Normalization.NONE
or Normalization.UNIT_LEN
.seed
- the random seed for creation of the units' weight vectors.public GrowingLayer(int id, Unit su, int xSize, int ySize, java.lang.String metricName, int dim, boolean normalized, boolean usePCA, long seed, InputData data)
id
- the unique id of the layer in a hierarchy.su
- the pointer to the corresponding unit in the upper layer map.xSize
- the number of units in horizontal direction.ySize
- the number of units in vertical direction.metricName
- the name of the distance metric to use.dim
- the dimensionality of the weight vectors.normalized
- the type of normalization that is applied to the weight vectors of newly created units. This is
usually Normalization.NONE
or Normalization.UNIT_LEN
.seed
- the random seed for creation of the units' weight vectors.public GrowingLayer(int id, Unit su, int xSize, int ySize, int zSize, java.lang.String metricName, int dim, boolean normalized, boolean usePCA, long seed, InputData data)
id
- the unique id of the layer in a hierarchy.su
- the pointer to the corresponding unit in the upper layer map.xSize
- the number of units in horizontal direction.ySize
- the number of units in vertical direction.zSize
- the number of units in depthmetricName
- the name of the distance metric to use.dim
- the dimensionality of the weight vectors.normalized
- the type of normalization that is applied to the weight vectors of newly created units. This is
usually Normalization.NONE
or Normalization.UNIT_LEN
.seed
- the random seed for creation of the units' weight vectors.public GrowingLayer(int id, Unit su, int xSize, int ySize, java.lang.String metricName, int dim, double[][][] vectors, long seed) throws SOMToolboxException
vectors
.xSize
- the number of columns.ySize
- the number of rows.metricName
- the name of the distance metric to use.dim
- the dimensionality of the weight vectors.vectors
- the three dimensional array of d
dimensional weight vectors.seed
- the random seed for creation of the units' weight vectors.SOMToolboxException
- if arguments x
, y
and d
do not correspond to
the dimensions of argument vectors
.public GrowingLayer(int id, Unit su, int xSize, int ySize, int zSize, java.lang.String metricName, int dim, double[][][][] vectors, long seed) throws SOMToolboxException
vectors
.xSize
- the number of columns.ySize
- the number of rows.zSize
- the depthmetricName
- the name of the distance metric to use.dim
- the dimensionality of the weight vectors.vectors
- the two dimensional array of d
dimensional weight vectors.seed
- the random seed for creation of the units' weight vectors.SOMToolboxException
- if arguments x
, y
and d
do not correspond to
the dimensions of argument vectors
.protected static double[][][][] addDimension(int x, int y, double[][][] vec)
private void initSuperUnit(int id, Unit su)
public boolean equalWeights(GrowingLayer otherLayer)
GrowingLayer
are equal in their weight (model) vectors. Other
information, such as mapping of vectors, labels, is not considered. This method can e.g. be utilised to check if
two layers have been trained equally.private int getDimension(int x, int y, int z, double[][][][] vectors)
public void calculateQuantizationErrorForUnits()
public void clearLabels()
public void clearMappedInput()
public Unit[] getAllUnits()
getAllUnits
in interface Layer
public java.util.ArrayList<GrowingSOM> getAllSubMaps()
public Unit[][] get2DUnits()
public Unit[][][] getUnits()
public boolean hasMappedInput(int x, int y)
public java.lang.String[] getAllMappedDataNames(boolean sort)
sort
- indicates whether the labels should be sorted (alphabetically)public java.util.ArrayList<java.lang.String> getAllMappedDataNamesAsList()
public java.lang.String[] getAllMappedDataNames()
public double[][][] getComponentPlane3D(int component)
public double[][] getComponentPlane(int component)
Layer
component
. Returns
null
, if the argument component
is out of range.getComponentPlane
in interface Layer
component
- the index of the component.null
if argument component
is invalid.public double[][] getComponentPlane(int component, int z)
Layer
component
. Returns
null
, if the argument component
is out of range.getComponentPlane
in interface Layer
component
- the index of the component.z
- TODOnull
if argument component
is invalid.public double[][] getExtremes() throws LayerAccessException
LayerAccessException
public int[][] getBinAssignment(int component, int bins)
public java.awt.geom.Point2D[] getBinCentres(int[][] binAssignment, int bins)
public java.awt.geom.Point2D[][] getBinCentres(int bins)
public java.util.ArrayList<ComponentLine2D> getBinCentresAsList(int bins)
public double getBinDeviation(int[][] binAssignment, int bins)
public double[] getDeviation(int bins)
private int[][] getRegionAssignement(int[][] binAssignement, int numberOfBins) throws LayerAccessException
LayerAccessException
private void processRegionRecursive(int[][] binAssignment, int[][] regionAssignment, int x, int y) throws LayerAccessException
LayerAccessException
private int getNumberOfRegions(int[][] regionAssignement)
public java.util.ArrayList<ComponentRegionCount> getNumberOfRegions(int bins) throws LayerAccessException
LayerAccessException
public int getDim()
private Unit getErrorUnit(QualityMeasure qm, java.lang.String methodName)
public java.lang.String getUnitPath()
public java.lang.String getIdString()
Layer
getIdString
in interface Layer
public int getLevel()
Layer
public double getMapDistance(int x1, int y1, int x2, int y2)
public double getMapDistance(int x1, int y1, int z1, int x2, int y2, int z2)
Layer
getMapDistance
in interface Layer
x1
- the horizontal position of the first unit.y1
- the vertical position of the first unit.z1
- the height position of the first unit.x2
- the horizontal position of the second unit.y2
- the vertical position of the second unit.z2
- the height position of the second unit.public double getMapDistance(Unit u1, Unit u2)
Layer
getMapDistance
in interface Layer
u1
- the first unit.u2
- the second unit.public double getMapDistanceSq(int x1, int y1, int z1, int x2, int y2, int z2)
public DistanceMetric getMetric()
protected Unit getMostDissimilarNeighbor(Unit u)
u
with the most distant weight vector.u
- the unit for which the most dissimilar neighbor should be determined.public QualityMeasure getQualityMeasure()
Layer
getQualityMeasure
in interface Layer
null
if not existent.public java.lang.String getRevision()
Layer
getRevision
in interface Layer
public Unit getSuperUnit()
null
if none exists.null
if none exists.public Unit getUnit(int x, int y) throws LayerAccessException
Layer
Unit
at the position specified by the x
and y
arguments. A
LayerAccessException
is thrown, if the coordinates are invalid.getUnit
in interface Layer
x
- the horizontal position on the map layer.y
- the vertical position on the map layer.LayerAccessException
- if the coordinates are out of range.public Unit getUnit(int x, int y, int z) throws LayerAccessException
Layer
Unit
at the position specified by the x
and y
arguments. A
LayerAccessException
is thrown, if the coordinates are invalid.getUnit
in interface Layer
x
- the horizontal position on the map layer.y
- the vertical position on the map layer.z
- TODOLayerAccessException
- if the coordinates are out of range.public int getUnitIndex(int x, int y)
getAllUnits()
.public Unit getUnitForIndex(int index) throws LayerAccessException
LayerAccessException
public Unit getUnitForDatum(java.lang.String name)
Layer
name
is mapped.getUnitForDatum
in interface Layer
name
- the name of the input datum to be searched for.null
if the datum is not found on the map.public Unit getWinner(InputDatum input, DistanceMetric metric)
input
.input
- the input datum for which the winner unit will be searched.metric
- the metric to be used.public Unit getWinner(InputDatum input, AbstractWeightedMetric metric)
public Unit getWinner(InputDatum input)
input
.input
- the input datum for which the winner unit will be searched.public Unit getWinnerFromQuery(java.lang.String query, SOMLibTemplateVector templateVector)
public Unit[] getWinnersFromQuery(java.lang.String query, int num, SOMLibTemplateVector templateVector)
public java.lang.String[] getWinningInputDataFromQuery(java.lang.String query, int num, SOMLibTemplateVector templateVector)
private double[] getInputVector(java.lang.String query, SOMLibTemplateVector templateVector)
public Unit[] getWinners(InputDatum input, int num, DistanceMetric metric)
input
- the input datum for which the best-matching units will be searched.num
- the number of best-matching units.public Unit[] getWinners(InputDatum input, int num)
public UnitDistance[] getWinnersAndDistances(InputDatum input, int num)
input
- the input datum for which the winner unit will be searched.num
- the number of best-matching units.Vector
containing an array of Unit (elementAt(0)) and array of double (elementAt(1))
containing best-matching units sorted ascending by distance from the input datum.public int getXSize()
Layer
public int getYSize()
Layer
public int getZSize()
Layer
public int getUnitCount()
public boolean hasNeighbours(int x, int y) throws LayerAccessException
LayerAccessException
public boolean hasNeighbours(int x, int y, int z) throws LayerAccessException
LayerAccessException
public boolean isEdgeColumn(int x) throws LayerAccessException
LayerAccessException
public boolean isEdgeRow(int y) throws LayerAccessException
LayerAccessException
private void insertRowColumn(Unit a, Unit b, ProgressListener listener)
a
and b
.a
- a unit on the layer.b
- a unit on the layer.private void mapCompleteDataAfterTraining(InputData data)
data
- input data to be mapped onto layer.public void mapData(InputData data)
data
- input data to be mapped onto layer.public Unit mapDatum(InputDatum datum)
datum
- input datum to be mapped onto the layer.public void setTrainingInterruptionListener(TrainingInterruptionListener t, int i)
TrainingInterruptionListener
interface to perform actions in
certain intervals during training determined by argument i
.t
- the listening object.i
- the number of training cycles after which the training process is interrupted.public QualityMeasure train(InputData data, double iniLearnrate, double iniSigma, int numIterations, double tau, java.lang.String qualityMeasureName, SOMProperties trainingProps)
tau
is 1, a fix-sized layer is
trained, otherwise the layer grows until a certain quality criterion determined by tau
and the mean
quantization error of the data (which is automatically calculated) is reached. The process ends with all training
data being mapped onto the growing SOM. The units' quantization errors are calculated.data
- input data to train the layer with.iniLearnrate
- initial value of learnrate.iniSigma
- initial sigma determining the neighborhood of the winner.numIterations
- the number of iterations until the mapping quality check.tau
- the fraction of the map's quantization error that determines the quality of the mapping.public QualityMeasure train(InputData data, double iniLearnrate, double iniSigma, int numIterations, int startIteration, double tau, java.lang.String qualityMeasureName, SOMProperties trainingProps)
tau
is 1, a fix-sized layer is
trained, otherwise the layer grows until a certain quality criterion determined by tau
and the mean
quantization error of the data (which is automatically calculated) is reached. The process ends with all training
data being mapped onto the growing SOM. The units' quantization errors are calculated.data
- input data to train the layer with.iniLearnrate
- initial value of learnrate.iniSigma
- initial sigma determining the neighborhood of the winner.numIterations
- the number of iterations until the mapping quality check.startIteration
- start with iteration x -- important for Lernrate / Sigma calculationtau
- the fraction of the map's quantization error that determines the quality of the mapping.public QualityMeasure train(InputData data, double initialLearnrate, double initialSigma, int numIterations, double tau, double targetQualityValue, java.lang.String qualityMeasureName, SOMProperties trainingProps)
tau
is 1, a fix-sized layer is
trained, otherwise the layer grows until a certain quality criterion determined by tau
and the mean
quantization error specified by argument mqe0
is reached. The process ends with all training data
being mapped onto the growing SOM. The units' quantization errors are calculated.data
- input data to train the layer with.initialLearnrate
- initial value of learnrate.initialSigma
- initial sigma determining the neighbourhood of the winner.numIterations
- the number of iterations until the mapping quality check.tau
- the fraction of the map's quantisation error that determines the quality of the mapping.targetQualityValue
- mean quantisation error determining the desired granularity of data representation.
Used for layers in GHSOMs.public QualityMeasure train(InputData data, double initialLearnrate, double initialSigma, int numIterations, int startIteration, double tau, double targetQualityValue, java.lang.String qualityMeasureName, SOMProperties trainingProps)
tau
is 1, a fix-sized layer is
trained, otherwise the layer grows until a certain quality criterion determined by tau
and the mean
quantization error specified by argument mqe0
is reached. The process ends with all training data
being mapped onto the growing SOM. The units' quantization errors are calculated.data
- input data to train the layer with.numIterations
- the number of iterations until the mapping quality check.startIteration
- start with iteration x -- important for Learnrate / Sigma calculationtau
- the fraction of the map's quantisation error that determines the quality of the mapping.targetQualityValue
- mean quantisation error determining the desired granularity of data representation.
Used for layers in GHSOMs.initialLearnrate
- initial value of learnrate.initialSigma
- initial sigma determining the neighbourhood of the winner.private void trainSpecial(InputData data, int numIterations, int startIteration, SOMProperties trainingProps, double initialLearnrate, double initialSigma, double expParam, double expParam2, SOMLibClassInformation classInfo, double minProbability, ProgressListener progressWriter)
private void trainNormal(InputData data, int numIterations, int startIteration, SOMProperties trainingProps, double initialLearnrate, double initialSigma, double expParam, double expParam2, ProgressListener progressWriter)
private boolean specialClassMode(SOMProperties trainingProps)
private void initCPURanges()
private void printInfo(double targetQualityValue, java.lang.String[] qmNameMethod, QualityMeasure qm) throws QualityMeasureNotFoundException
QualityMeasureNotFoundException
private void updateUnits(Unit winner, InputDatum input, double learnrate, double sigma)
private void updateUnitsNoBorder(Unit winner, InputDatum input, double learnrate, double sigma)
winner
- the winner unit.input
- the input datum.learnrate
- the learnrate.sigma
- the width of the Gaussian determining the neighborhood radius.protected void updateUnitsNormal(Unit winner, InputDatum input, double learnrate, double sigma)
winner
- the winner unit.input
- the input datum.learnrate
- the learnrate.sigma
- the width of the Gaussian determining the neighborhood radius.private void updateUnitsInArea(Unit winner, double learnrate, double opt1, double[] inputVector, Cuboid range)
private void updateUnitsInArea(Unit winner, double learnrate, double opt1, double[] inputVector, int startX, int endX, int startY, int endY, int startZ, int endZ)
public int getNumberOfNotEmptyUnits() throws LayerAccessException
LayerAccessException
public int getMaximumNumberOfMappedInputs()
InputContainer.getNumberOfMappedInputs()
public void setQualityMeasure(java.lang.String qualityMeasureName)
public InputData getData()
public java.lang.String[] getNNearestInputs(java.lang.String datumlabel, int n, InputData data) throws LayerAccessException, MetricException
LayerAccessException
MetricException
public java.lang.String[] getNNearestInputs(Unit u, int n) throws LayerAccessException
LayerAccessException
private java.lang.String[] getFirstNLabels(int n, java.util.ArrayList<InputNameDistance> items)
protected java.util.ArrayList<Unit> getNeighbouringUnits(Unit u) throws LayerAccessException
LayerAccessException
public java.util.ArrayList<Unit> getNeighbouringUnits(int x, int y) throws LayerAccessException
LayerAccessException
private java.util.ArrayList<Unit> getNeighbouringUnits(int x, int y, int z) throws LayerAccessException
LayerAccessException
protected java.util.ArrayList<Unit> getNeighbouringUnits(Unit u, double radius) throws LayerAccessException
getNeighbouringUnits(int, int, int, double)
LayerAccessException
public java.util.ArrayList<Unit> getNeighbouringUnits(int x, int y, double radius) throws LayerAccessException
getNeighbouringUnits(int, int, int, double)
LayerAccessException
public java.util.ArrayList<Unit> getNeighbouringUnits(int x, int y, int z, double radius) throws LayerAccessException
getMapDistance(int, int, int, int, int, int)
for map
distance computationLayerAccessException
public cern.colt.matrix.DoubleMatrix2D getUnitDistanceMatrix()
public boolean isValidUnitLocation(java.awt.Point pos)
public boolean isValidUnitLocation(int x, int y)
public int getNumberOfMappedInputs()
Layer
getNumberOfMappedInputs
in interface Layer
public InputCorrections computeUnitFeatureWeights(InputCorrections corrections, InputData data, Unit.FeatureWeightMode mode) throws SOMToolboxException
SOMToolboxException
public double maxNeighbourhoodRadius()
public double neighbourhoodFeatureWeight(double dist, int maxDist)
public static int getNO_CPUS()
public static void setNO_CPUS(int no_cpus)
public void flip(GrowingLayer.Flip flip)
public void rotate(int rotation) throws SOMToolboxException
SOMToolboxException
public void rotate(GrowingLayer.Rotation rotation)
public static void checkRotation(int rotation) throws SOMToolboxException
SOMToolboxException
public java.lang.String printUnitIndices()
public java.lang.String printSize()
public void setCommonVectorLabelPrefix(java.lang.String commonVectorLabelPrefix)
public java.lang.String getCommonVectorLabelPrefix()
public Layer.GridLayout getGridLayout()
getGridLayout
in interface Layer
public Layer.GridTopology getGridTopology()
getGridTopology
in interface Layer
public void setGridLayout(Layer.GridLayout gridLayout)
public void setGridTopology(Layer.GridTopology gridTopology)
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
clone
in class java.lang.Object
java.lang.CloneNotSupportedException
Object.clone()
public AdaptiveCoordinatesVirtualLayer getVirtualLayer()