AI-NeuralNet-SOM
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
examples/load_save.pl view on Meta::CPAN
use strict;
use Data::Dumper;
use AI::NeuralNet::SOM::Rect;
{
my $nn = new AI::NeuralNet::SOM::Rect (output_dim => "5x6",
input_dim => 3);
$nn->initialize;
$nn->train (400, ([ 3, 2, 4 ], [ -1, -1, -1 ], [ 0, 4, -3]));
# now we freeze the thing
use Storable;
store $nn, '/tmp/somnia';
# and forget it
}
{ # get it back, get it back
my $nn = retrieve('/tmp/somnia');
warn Dumper $nn;
# ....
}
__END__
use AI::NeuralNet::SOM::Rect;
#my @vs = ([1,-0.5], [0,1]);
#my $dim = 2;
my $epsilon = 0.001;
$nn->initialize; # random
my @mes = $nn->train ($epochs, @vs);
warn "random: length until error is < $epsilon ". scalar (grep { $_ >= $epsilon } @mes);
}
{ # constant initialisation
my $nn = new AI::NeuralNet::SOM::Rect (output_dim => "5x6",
input_dim => $dim);
$nn->initialize ($vs[-1]);
my @mes = $nn->train ($epochs, @vs);
warn "constant: length until error is < $epsilon ". scalar (grep { $_ >= $epsilon } @mes);
}
{ # eigenvector initialisation
my $nn = new AI::NeuralNet::SOM::Rect (output_dim => "5x6",
input_dim => $dim);
my @training_vectors; # find these training vectors
{ # and prime them with this eigenvector stuff;
use PDL;
my $A = pdl \@vs;
while ($A->getdim(0) < $A->getdim(1)) { # make the beast quadratic
$A = append ($A, zeroes (1)); # by padding zeroes
}
my ($E, $e) = eigens_sym $A;
view all matches for this distributionview release on metacpan - search on metacpan
( run in 0.582 second using v1.00-cache-2.02-grep-82fe00e-cpan-2c419f77a38b )