at.tuwien.ifs.somtoolbox.layers
Class MnemonicGrowingLayer

java.lang.Object
  extended by at.tuwien.ifs.somtoolbox.layers.GrowingLayer
      extended by at.tuwien.ifs.somtoolbox.layers.MnemonicGrowingLayer
All Implemented Interfaces:
Layer

public class MnemonicGrowingLayer
extends GrowingLayer

A mnemonic layer is a rectangular layer that might not have all grid positions occupied by units.

Version:
$Id: MnemonicGrowingLayer.java 3590 2010-05-21 10:43:45Z mayer $
Author:
Rudolf Mayer

Nested Class Summary
 
Nested classes/interfaces inherited from class at.tuwien.ifs.somtoolbox.layers.GrowingLayer
GrowingLayer.Flip, GrowingLayer.Rotation, GrowingLayer.UpdaterThread
 
Nested classes/interfaces inherited from interface at.tuwien.ifs.somtoolbox.layers.Layer
Layer.GridLayout, Layer.GridTopology
 
Field Summary
(package private)  Integer[][][][][][] distanceMatrix_
           
private  int unitCount
           
 
Fields inherited from class at.tuwien.ifs.somtoolbox.layers.GrowingLayer
dim, gridLayout, gridTopology, maxFeatureValues, metric, metricWeighted, minFeatureValues, ROTATIONS, skippedNonSelected, trainedNonSelected, unitDistanceMatrix, units, xSize, ySize, zSize
 
Constructor Summary
MnemonicGrowingLayer(int id, Unit su, int x, int y, int z, String metricName, int d, double[][][][] vectors, long seed)
           
MnemonicGrowingLayer(int id, Unit su, int x, int y, String metricName, int d, double[][][] vectors, long seed)
           
 
Method Summary
 void clearMappedInput()
          Removes all mapped input data from the units.
 void countDistances(int distanceFromStart, Unit startUnit, Unit currentUnit)
           
 Unit[] getAllUnits()
          Returns all units of the layer in an array.
 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.
 int getUnitCount()
           
 Unit getWinner(InputDatum input)
          Returns the winner unit for a given input datum specified by argument input.
 UnitDistance[] getWinnersAndDistances(InputDatum input, int num)
          Returns a number of best-matching units and distances sorted by distance (ascending) for a given input datum.
 void initDistances()
           
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.
 
Methods inherited from class at.tuwien.ifs.somtoolbox.layers.GrowingLayer
addDimension, calculateQuantizationErrorForUnits, checkRotation, clearLabels, clone, computeUnitFeatureWeights, equalWeights, flip, get2DUnits, getAllMappedDataNames, getAllMappedDataNames, getAllMappedDataNamesAsList, getAllSubMaps, getBinAssignment, getBinCentres, getBinCentres, getBinCentresAsList, getBinDeviation, getCommonVectorLabelPrefix, getComponentPlane, getComponentPlane, getComponentPlane3D, getData, getDeviation, getDim, getExtremes, getGridLayout, getGridTopology, getIdentifier, getIdString, getLevel, getMapDistance, getMapDistanceSq, getMapDistanceSq, getMetric, getMostDissimilarNeighbor, getNeighbouringUnits, getNeighbouringUnits, getNeighbouringUnits, getNeighbouringUnits, getNeighbouringUnits, getNNearestInputs, getNNearestInputs, getNO_CPUS, getNumberOfMappedInputs, getNumberOfNotEmptyUnits, getNumberOfRegions, getQualityMeasure, getRevision, getSuperUnit, getUnit, getUnit, getUnitDistanceMatrix, getUnitForDatum, getUnitForIndex, getUnitIndex, getUnits, getVirtualLayer, getWinner, getWinner, getWinnerFromQuery, getWinners, getWinners, getWinnersFromQuery, getWinningInputDataFromQuery, getXSize, getYSize, getZSize, hasMappedInput, hasNeighbours, hasNeighbours, isEdgeColumn, isEdgeRow, isValidUnitLocation, isValidUnitLocation, mapData, mapDatum, maxNeighbourhoodRadius, neighbourhoodFeatureWeight, printSize, printUnitIndices, rotate, rotate, setCommonVectorLabelPrefix, setGridLayout, setGridTopology, setNO_CPUS, setQualityMeasure, setTrainingInterruptionListener, train, train, train, train
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

distanceMatrix_

Integer[][][][][][] distanceMatrix_

unitCount

private int unitCount
Constructor Detail

MnemonicGrowingLayer

public MnemonicGrowingLayer(int id,
                            Unit su,
                            int x,
                            int y,
                            String metricName,
                            int d,
                            double[][][] vectors,
                            long seed)
                     throws SOMToolboxException
Throws:
SOMToolboxException

MnemonicGrowingLayer

public MnemonicGrowingLayer(int id,
                            Unit su,
                            int x,
                            int y,
                            int z,
                            String metricName,
                            int d,
                            double[][][][] vectors,
                            long seed)
                     throws SOMToolboxException
Throws:
SOMToolboxException
Method Detail

countDistances

public void countDistances(int distanceFromStart,
                           Unit startUnit,
                           Unit currentUnit)

initDistances

public void initDistances()

getWinner

public Unit getWinner(InputDatum input)
Description copied from class: GrowingLayer
Returns the winner unit for a given input datum specified by argument input.

Overrides:
getWinner in class GrowingLayer
Parameters:
input - the input datum for which the winner unit will be searched.
Returns:
the winner unit.

clearMappedInput

public void clearMappedInput()
Description copied from class: GrowingLayer
Removes all mapped input data from the units.

Overrides:
clearMappedInput in class GrowingLayer

getMapDistance

public double getMapDistance(int x1,
                             int y1,
                             int x2,
                             int y2)
Overrides:
getMapDistance in class GrowingLayer

getMapDistance

public double getMapDistance(int x1,
                             int y1,
                             int z1,
                             int x2,
                             int y2,
                             int z2)
Description copied from interface: Layer
Returns the distance between two units on the map grid.

Specified by:
getMapDistance in interface Layer
Overrides:
getMapDistance in class GrowingLayer
Parameters:
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.
Returns:
the distance between two units.

updateUnitsNormal

protected void updateUnitsNormal(Unit winner,
                                 InputDatum input,
                                 double learnrate,
                                 double sigma)
Description copied from class: GrowingLayer
Updates the weight vectors of the all map units with respect to the input datum and the according winner unit.

Overrides:
updateUnitsNormal in class GrowingLayer
Parameters:
winner - the winner unit.
input - the input datum.
learnrate - the learnrate.
sigma - the width of the Gaussian determining the neighborhood radius.

getAllUnits

public Unit[] getAllUnits()
Description copied from class: GrowingLayer
Returns all units of the layer in an array.

Specified by:
getAllUnits in interface Layer
Overrides:
getAllUnits in class GrowingLayer
Returns:
all units of the layer in an array.

getWinnersAndDistances

public UnitDistance[] getWinnersAndDistances(InputDatum input,
                                             int num)
Description copied from class: GrowingLayer
Returns a number of best-matching units and distances sorted by distance (ascending) for a given input datum. If the number of best-matching units is greater than the total number of units on the map, all units of the map are returned (appropriately ranked).

Overrides:
getWinnersAndDistances in class GrowingLayer
Parameters:
input - the input datum for which the winner unit will be searched.
num - the number of best-matching units.
Returns:
the 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.

getUnitCount

public int getUnitCount()
Overrides:
getUnitCount in class GrowingLayer