AI-NeuralNet-SOM
view release on metacpan or search on metacpan
lib/AI/NeuralNet/SOM.pm view on Meta::CPAN
together with some visualisation software. And while it is not (yet)
optimized for speed, some consideration has been given that it is not
overly slow.
Particular emphasis has been given that the package plays nicely with
others. So no use of files, no arcane dependencies, etc.
=head2 Scenario
The basic idea is that the neural network consists of a 2-dimensional
array of N-dimensional vectors. When the training is started these
vectors may be completely random, but over time the network learns
from the sample data, which is a set of N-dimensional vectors.
Slowly, the vectors in the network will try to approximate the sample
vectors fed in. If in the sample vectors there were clusters, then
these clusters will be neighbourhoods within the rectangle (or
whatever topology you are using).
Technically, you have reduced your dimension from N to 2.
lib/AI/NeuralNet/SOM.pm view on Meta::CPAN
=item C<learning_rate>: (optional, default C<0.1>)
This is a magic number which controls how strongly the vectors in the grid can be influenced. Stronger
movement can mean faster learning if the clusters are very pronounced. If not, then the movement is
like noise and the convergence is not good. To mediate that effect, the learning rate is reduced
over the iterations.
=item C<sigma0>: (optional, defaults to radius)
A non-negative number representing the start value for the learning radius. Practically, the value
should be chosen in such a way to cover a larger part of the map. During the learning process this
value will be narrowed down, so that the learning radius impacts less and less neurons.
B<NOTE>: Do not choose C<1> as the C<log> function is used on this value.
=back
Subclasses will (re)define some of these parameters and add others:
Example:
lib/AI/NeuralNet/SOM.pm view on Meta::CPAN
I<$nn>->initialize
You need to initialize all vectors in the map before training. There are several options
how this is done:
=over
=item providing data vectors
If you provide a list of vectors, these will be used in turn to seed the neurons. If the list is
shorter than the number of neurons, the list will be started over. That way it is trivial to
zero everything:
$nn->initialize ( [ 0, 0, 0 ] );
=item providing no data
Then all vectors will get randomized values (in the range [ -0.5 .. 0.5 ]).
=item using eigenvectors (see L</HOWTOS>)
lib/AI/NeuralNet/SOM/Hexa.pm view on Meta::CPAN
} else {
die "output dimension must be positive integer";
}
if ($self->{input_dim} > 0) {
$self->{_Z} = $self->{input_dim};
} else {
die "input dimension must be positive integer";
}
$self->{_R} = $self->{_D} / 2;
$self->{_Sigma0} = $options{sigma0} || $self->{_R}; # impact distance, start value
$self->{_L0} = $options{learning_rate} || 0.1; # learning rate, start value
return $self;
}
=pod
=head2 Methods
=over
lib/AI/NeuralNet/SOM/Rect.pm view on Meta::CPAN
die "output dimension does not have format MxN";
}
if ($self->{input_dim} > 0) {
$self->{_Z} = $self->{input_dim};
} else {
die "input dimension must be positive integer";
}
($self->{_R}) = map { $_ / 2 } sort {$b <= $a } ($self->{_X}, $self->{_Y}); # radius
$self->{_Sigma0} = $options{sigma0} || $self->{_R}; # impact distance, start value
$self->{_L0} = $options{learning_rate} || 0.1; # learning rate, start value
return $self;
}
=pod
=head2 Methods
=cut
sub initialize {
( run in 0.264 second using v1.01-cache-2.11-cpan-0d8aa00de5b )