AI-NeuralNet-SOM
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
lib/AI/NeuralNet/SOM/Rect.pm view on Meta::CPAN
package AI::NeuralNet::SOM::Rect;
use strict;
use warnings;
use Data::Dumper;
use base qw(AI::NeuralNet::SOM);
use AI::NeuralNet::SOM::Utils;
=pod
=head1 NAME
AI::NeuralNet::SOM::Rect - Perl extension for Kohonen Maps (rectangular topology)
=head1 SYNOPSIS
use AI::NeuralNet::SOM::Rect;
my $nn = new AI::NeuralNet::SOM::Rect (output_dim => "5x6",
input_dim => 3);
$nn->initialize;
$nn->train (30,
[ 3, 2, 4 ],
[ -1, -1, -1 ],
[ 0, 4, -3]);
print $nn->as_data;
=head1 INTERFACE
=head2 Constructor
The constructor takes the following arguments (additionally to those in the base class):
=over
=item C<output_dim> : (mandatory, no default)
A string of the form "3x4" defining the X and the Y dimensions.
=back
Example:
my $nn = new AI::NeuralNet::SOM::Rect (output_dim => "5x6",
input_dim => 3);
=cut
sub new {
my $class = shift;
my %options = @_;
my $self = bless { %options }, $class;
if ($self->{output_dim} =~ /(\d+)x(\d+)/) {
$self->{_X} = $1 and $self->{_Y} = $2;
} else {
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";
}
view all matches for this distributionview release on metacpan - search on metacpan
( run in 0.560 second using v1.00-cache-2.02-grep-82fe00e-cpan-2c419f77a38b )