org.joone.engine
Class SpatialMap

java.lang.Object
  extended by org.joone.engine.SpatialMap
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
CircularSpatialMap, GaussianSpatialMap

public abstract class SpatialMap
extends java.lang.Object
implements java.io.Serializable

SpatialMap is intended to be an abstract spatial map for use with a GaussianLayer. Custom SpatialMap's need to extend the ApplyNeighborhood method and implement it based on their own spatial shape implementation. The Gaussian spatial size is updated if the current epoch is less than the ordering phase, it is also reduced over the ordering phase based on the time constant.

See Also:
Serialized Form

Field Summary
(package private)  double TimeConstant
           
 
Constructor Summary
SpatialMap()
           
 
Method Summary
abstract  void ApplyNeighborhoodFunction(double[] distances, double[] n_outs, boolean isLearning)
          Applies the neighborhood strategy based on this spatial maps implementation.
protected  double distanceBetween(int x1, int y1, int z1, int x2, int y2, int z2)
          Calculates the squared distance between vector (x1,y1,z1) and (x2,y2,z2) and returns the result.
protected  void extractWinner(double[] distances)
          Extracts the X,Y,Z co-ordinates of the winning neuron in this spatial map.
 double getCurrentGaussianSize()
          Gets the current gaussian size of the spatial neighborhood.
 double getInitialGaussianSize()
          Gets the size of the spatial neighborhood.
 int getMapDepth()
          Gets the depth of this spatial map.
 int getMapHeight()
          Gets the height of this spatial map.
 int getMapWidth()
          Gets the width of this spatial map.
 int getOrderingPhase()
          Getter for property orderingPhase.
 double getTimeConstant()
          Getter for property TimeConstant.
 int getTotalEpochs()
          Gets the total number of epochs for the current session.
protected  int getWinnerX()
           Returns the X Co-ordinate of the current winning neuron.
protected  int getWinnerY()
          Returns the Y Co-ordinate of the current winning neuron.
protected  int getWinnerZ()
          Returns the Z Co-ordinate of the current winning neuron.
 void init(int total_epochs)
          Initialises this spatial map according to the total number of epochs/cycles.
 void setCurrentGaussianSize(double size)
          Sets the current guassian size of the spatial neighborhood.
 void setInitialGaussianSize(double size)
          Sets the initial guassian size of the spatial neighborhood.
 void setMapDepth(int d)
          Sets the depth of this spatial map.
 void setMapDimensions(int x, int y, int z)
          Sets the dimensions of the spatial map.
 void setMapHeight(int h)
          Sets the height of this spatial map.
 void setMapWidth(int w)
          Sets the width of this spatial map.
 void setOrderingPhase(int orderingPhase)
          Setter for property orderingPhase.
 void setTimeConstant(double TimeConstant)
          Setter for property TimeConstant.
 void updateCurrentGaussianSize(int current_epoch)
          Updates the current Gaussian Size depending on the current epoch and the time constant.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TimeConstant

double TimeConstant
Constructor Detail

SpatialMap

public SpatialMap()
Method Detail

init

public final void init(int total_epochs)

Initialises this spatial map according to the total number of epochs/cycles.

Parameters:
total_epochs - The total number of epochs that will be used.

getTotalEpochs

public final int getTotalEpochs()

Gets the total number of epochs for the current session.

Returns:
The total number of epochs for the current session.

setInitialGaussianSize

public final void setInitialGaussianSize(double size)

Sets the initial guassian size of the spatial neighborhood.

Parameters:
size - The size of the neighborhood.

getInitialGaussianSize

public final double getInitialGaussianSize()

Gets the size of the spatial neighborhood.

Returns:
The size of the spatial neighborhood.

setCurrentGaussianSize

public final void setCurrentGaussianSize(double size)

Sets the current guassian size of the spatial neighborhood.

Parameters:
size - The current guassian size of the spatial neighborhood.

getCurrentGaussianSize

public final double getCurrentGaussianSize()

Gets the current gaussian size of the spatial neighborhood.

Returns:
The current gaussian size of the spatial neighborhood.

updateCurrentGaussianSize

public final void updateCurrentGaussianSize(int current_epoch)

Updates the current Gaussian Size depending on the current epoch and the time constant.

Parameters:
current_epoch - The current epoch or cycle.

ApplyNeighborhoodFunction

public abstract void ApplyNeighborhoodFunction(double[] distances,
                                               double[] n_outs,
                                               boolean isLearning)

Applies the neighborhood strategy based on this spatial maps implementation.

Parameters:
distances - The euclidean distances between input and weights calculated by previous synapse.
n_outs - The outputs of this spatial maps neighborhood strategy.
isLearning - Is the network in the learning phase.

extractWinner

protected final void extractWinner(double[] distances)
Extracts the X,Y,Z co-ordinates of the winning neuron in this spatial map. The co-ordinates are placed into internal variables, Co-ordinates can be accessed by using the getWinnerX() , getWinnerY() , getWinnerZ() methods. A neuron is considered the winner if it's distance between the input and weights vector is the smallest.

Parameters:
distances - The distances between the input and weights vector, this should be passed in by the previous synapse.

getWinnerX

protected final int getWinnerX()

Returns the X Co-ordinate of the current winning neuron.

Returns:
The X Co-ordinate of the current winning neuron.

getWinnerY

protected final int getWinnerY()

Returns the Y Co-ordinate of the current winning neuron.

Returns:
The Y Co-ordinate of the current winning neuron.

getWinnerZ

protected final int getWinnerZ()

Returns the Z Co-ordinate of the current winning neuron.

Returns:
The Z Co-ordinate of the current winning neuron.

setMapDimensions

public final void setMapDimensions(int x,
                                   int y,
                                   int z)

Sets the dimensions of the spatial map. Allows dimension setting in one call.

Parameters:
x - The x size or width of the map.
y - The y size or height of the map.
z - The z size of depth of the map.

setMapWidth

public final void setMapWidth(int w)
Sets the width of this spatial map.

Parameters:
w - The width or x size of the map.

setMapHeight

public final void setMapHeight(int h)
Sets the height of this spatial map.

Parameters:
h - The height or y size of the map.

setMapDepth

public final void setMapDepth(int d)
Sets the depth of this spatial map.

Parameters:
d - The depth or z size of the map.

getMapWidth

public final int getMapWidth()

Gets the width of this spatial map.

Returns:
The width of this spatial map.

getMapHeight

public final int getMapHeight()

Gets the height of this spatial map.

Returns:
The height of this spatial map.

getMapDepth

public final int getMapDepth()

Gets the depth of this spatial map.

Returns:
The depth of this spatial map.

distanceBetween

protected final double distanceBetween(int x1,
                                       int y1,
                                       int z1,
                                       int x2,
                                       int y2,
                                       int z2)

Calculates the squared distance between vector (x1,y1,z1) and (x2,y2,z2) and returns the result.

Parameters:
x1 - The x location of the first vector.
y1 - The y location of the first vector.
z1 - The z location of the first vector.
x2 - The x location of the second vector.
y2 - The y location of the second vector.
z2 - The z location of the second vector.
Returns:
The squared distance between vector (x1,y1,z1) and (x2,y2,z2)

getOrderingPhase

public int getOrderingPhase()
Getter for property orderingPhase.

Returns:
Value of property orderingPhase.

setOrderingPhase

public void setOrderingPhase(int orderingPhase)
Setter for property orderingPhase.

Parameters:
orderingPhase - New value of property orderingPhase.

getTimeConstant

public double getTimeConstant()
Getter for property TimeConstant.

Returns:
Value of property TimeConstant.

setTimeConstant

public void setTimeConstant(double TimeConstant)
Setter for property TimeConstant.

Parameters:
TimeConstant - New value of property TimeConstant.


Submit Feedback to pmarrone@users.sourceforge.net