Top Description Fields Constructors Methods
org.apache.commons.math3.ml.neuralnet.sofm

public Class KohonenUpdateAction

extends Object
implements UpdateAction
Class Inheritance
All Implemented Interfaces
org.apache.commons.math3.ml.neuralnet.UpdateAction
Imports
java.util.Collection, .HashSet, java.util.concurrent.atomic.AtomicLong, org.apache.commons.math3.analysis.function.Gaussian, org.apache.commons.math3.linear.ArrayRealVector, org.apache.commons.math3.ml.distance.DistanceMeasure, org.apache.commons.math3.ml.neuralnet.MapUtils, .Network, .Neuron, .UpdateAction

Update formula for Kohonen's Self-Organizing Map.
The update method modifies the features w of the "winning" neuron and its neighbours according to the following rule: wnew = wold + α e(-d / σ) * (sample - wold) where
This class is thread-safe as long as the arguments passed to the constructor are instances of thread-safe classes.
Each call to the update method will increment the internal counter used to compute the current values for Consequently, the function instances that compute those values (passed to the constructor of this class) must take into account whether this class's instance will be shared by multiple threads, as this will impact the training process.
Since
3.3

Field Summary

Modifier and TypeField and Description
private final DistanceMeasure
distance

Distance function.

private final LearningFactorFunction
learningFactor

Learning factor update function.

private final NeighbourhoodSizeFunction
neighbourhoodSize

Neighbourhood size update function.

private final AtomicLong

Constructor Summary

AccessConstructor and Description
public
KohonenUpdateAction(DistanceMeasure
Distance function.
distance
,
LearningFactorFunction
Learning factor update function.
learningFactor
,
NeighbourhoodSizeFunction
Neighbourhood size update function.
neighbourhoodSize
)

Method Summary

Modifier and TypeMethod and Description
private boolean

Returns:

true if the update succeeded, true if a concurrent update has been detected.
attemptNeuronUpdate
(Neuron
Neuron to be updated.
n
,
double[]
Training data.
features
,
double
Learning factor.
learningRate
)

Tries to update a neuron.

private double[]

Returns:

the new values for the features.
computeFeatures
(double[]
Current values of the features.
current
,
double[]
Training data.
sample
,
double
Learning factor.
learningRate
)

Computes the new value of the features set.

private Neuron

Returns:

the winning neuron.
findAndUpdateBestNeuron
(Network
Network.
net
,
double[]
Sample data.
features
,
double
Current learning factor.
learningRate
)

Searches for the neuron whose features are closest to the given sample, and atomically updates its features.

public long

Returns:

the current number of calls.
getNumberOfCalls
()

Retrieves the number of calls to the update method.

public void
update(Network
Network.
net
,
double[]
Training data.
features
)

Implements org.apache.commons.math3.ml.neuralnet.UpdateAction.update.

Updates the network in response to the sample features.

private void
updateNeighbouringNeuron(Neuron
Neuron to be updated.
n
,
double[]
Training data.
features
,
double
Learning factor.
learningRate
)

Atomically updates the given neuron.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

distanceback to summary
private final DistanceMeasure distance

Distance function.

learningFactorback to summary
private final LearningFactorFunction learningFactor

Learning factor update function.

neighbourhoodSizeback to summary
private final NeighbourhoodSizeFunction neighbourhoodSize

Neighbourhood size update function.

numberOfCallsback to summary
private final AtomicLong numberOfCalls

Number of calls to update(Network, double[]).

Constructor Detail

KohonenUpdateActionback to summary
public KohonenUpdateAction(DistanceMeasure distance, LearningFactorFunction learningFactor, NeighbourhoodSizeFunction neighbourhoodSize)
Parameters
distance:DistanceMeasure

Distance function.

learningFactor:LearningFactorFunction

Learning factor update function.

neighbourhoodSize:NeighbourhoodSizeFunction

Neighbourhood size update function.

Method Detail

attemptNeuronUpdateback to summary
private boolean attemptNeuronUpdate(Neuron n, double[] features, double learningRate)

Tries to update a neuron.

Parameters
n:Neuron

Neuron to be updated.

features:double[]

Training data.

learningRate:double

Learning factor.

Returns:boolean

true if the update succeeded, true if a concurrent update has been detected.

computeFeaturesback to summary
private double[] computeFeatures(double[] current, double[] sample, double learningRate)

Computes the new value of the features set.

Parameters
current:double[]

Current values of the features.

sample:double[]

Training data.

learningRate:double

Learning factor.

Returns:double[]

the new values for the features.

findAndUpdateBestNeuronback to summary
private Neuron findAndUpdateBestNeuron(Network net, double[] features, double learningRate)

Searches for the neuron whose features are closest to the given sample, and atomically updates its features.

Parameters
net:Network

Network.

features:double[]

Sample data.

learningRate:double

Current learning factor.

Returns:Neuron

the winning neuron.

getNumberOfCallsback to summary
public long getNumberOfCalls()

Retrieves the number of calls to the update method.

Returns:long

the current number of calls.

updateback to summary
public void update(Network net, double[] features)

Implements org.apache.commons.math3.ml.neuralnet.UpdateAction.update.

Doc from org.apache.commons.math3.ml.neuralnet.UpdateAction.update.

Updates the network in response to the sample features.

Parameters
net:Network

Network.

features:double[]

Training data.

updateNeighbouringNeuronback to summary
private void updateNeighbouringNeuron(Neuron n, double[] features, double learningRate)

Atomically updates the given neuron.

Parameters
n:Neuron

Neuron to be updated.

features:double[]

Training data.

learningRate:double

Learning factor.