AI-NeuralNet-Kohonen
view release on metacpan or search on metacpan
Revision history for Perl extension AI::NeuralNet::Kohonen.
0.142 08 August 2006 14:56
Forgot to include the .dat test file in previous version
Can't find it now. Updated tests to cope :(
0.141 Fri May 05 20:19:00 2006
Repacked
0.14 Fri May 05 20:19:00 2006
Updated SYNOPSIS from ::Visual code, and a minor bug:
thanks to diligent eye of Przemek Blaskiewicz
0.132 Web Apr 17 11:40:00 2003
Some minor interface changes.
It could be improved to use Perl Data Language (PDL), XS or C,
but then it's be reworking code that already exists open-source.
INSTALLATION
To install this module type the following:
perl Makefile.PL
make
make test
make install
DEPENDENCIES
This module requires these other modules and libraries:
AI::NeuralNet::Kohonen::Node
COPYRIGHT AND LICENCE
lib/AI/NeuralNet/Kohonen.pm view on Meta::CPAN
package AI::NeuralNet::Kohonen;
use vars qw/$VERSION/;
$VERSION = 0.142; # 08 August 2006 test lost input file
=head1 NAME
AI::NeuralNet::Kohonen - Kohonen's Self-organising Maps
=cut
use strict;
use warnings;
use Carp qw/croak cluck confess/;
t/AI-NeuralNet-Kohonen.t view on Meta::CPAN
package K_test;
use Test::More tests => 35;
use lib "../lib";
use strict;
use warnings;
use_ok ("AI::NeuralNet::Kohonen" => 0.14);
use_ok ("AI::NeuralNet::Kohonen::Node" => 0.12);
use_ok ("AI::NeuralNet::Kohonen::Input");
t/AI-NeuralNet-Kohonen.t view on Meta::CPAN
weight_dim => 2,
input => [
[1,2,3]
],
map_dim_x => 10,
map_dim_y => 20,
);
is($net->{map_dim_a},15);
# Node test
my $node = new AI::NeuralNet::Kohonen::Node;
is($node,undef) or BAIL_OUT();
$node = new AI::NeuralNet::Kohonen::Node(
weight => [0.1, 0.6, 0.5],
);
isa_ok( $node, 'AI::NeuralNet::Kohonen::Node');
is( $node->{dim}, 2);
my $input = new AI::NeuralNet::Kohonen::Input(
dim => 2,
values => [1,0,0],
t/AI-NeuralNet-Kohonen.t view on Meta::CPAN
$qerror += $targets->[0]->{values}->[$j]
- $net->{map}->[$bmu[$i]->[1]]->[$bmu[$i]->[2]]->{weight}->[$j];
}
is( $qerror, $net->quantise_error([ [1,0,0] ]));
}
SKIP: {
skip 'Lost the input file',9;
# Input file tests\n";
$net = AI::NeuralNet::Kohonen->new(
epochs => 0,
input_file => $dir.'ex.dat',
epoch_end => sub {print"."},
train_end => sub {print"\n"},
);
isa_ok( $net,'AI::NeuralNet::Kohonen');
isa_ok( $net->{input}, 'ARRAY');
is( scalar @{$net->{input}}, 3840);
is( $net->{map_dim_x}, 19);
is ($net->{input}->[$#{$net->{input}}]->{values}->[4], 406.918518);
is( ref $net->{input}->[$#{$net->{input}}]->{values}, 'ARRAY');
diag "Training on a big file: this is SLOW, sorry\n";
is($net->train,1);
my $filename = substr(time,0,8);
ok($net->save_file($filename),"Saved file as ".$filename);
ok(unlink($filename),'Unlinked test file '.$filename);
}
sub BAIL_OUT {
diag "BAIL_OUT:",@_? @_ : "";
exit;
}
( run in 0.358 second using v1.01-cache-2.11-cpan-87723dcf8b7 )