AI-NeuralNet-Kohonen
view release on metacpan or search on metacpan
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");
my ($dir) = $0 =~ /^(.*?)[^\\\/]+$/;
my $net = new AI::NeuralNet::Kohonen;
is($net,undef);
$net = new AI::NeuralNet::Kohonen(
weight_dim => 2,
input => [
[1,2,3]
],
);
isa_ok( $net->{input}, 'ARRAY');
is( $net->{input}->[0]->[0],1);
is( $net->{input}->[0]->[1],2);
is( $net->{input}->[0]->[2],3);
is( $net->{map_dim_a},19);
$net = new AI::NeuralNet::Kohonen(
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],
);
is( sprintf("%.2f",$node->distance_from($input)), 1.19);
$net = AI::NeuralNet::Kohonen->new(
map_dim_x => 14,
map_dim_y => 10,
epoch_end => sub {print"."},
train_end => sub {print"\n"},
epochs => 2,
( run in 1.632 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )