AI-NeuralNet-SOM

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

Revision history for Perl extension AI::NeuralNet::SOM.

0.07  Sat May 24 08:53:26 CEST 2008
	- fix: Hexa::initialize: corner case when @data is empty not handled (tom fawcett)

0.06  Fri May 23 10:23:29 CEST 2008
	- fix: label '0' in label method (tom fawcett)
	- fix: value '0' in value method (rho)

0.05  Mi 16. Jan 20:58:19 CET 2008
	- improvement of documentation
	- training now holds sigma and l constant during an epoch, but applies ALL vectors (exactly once)

0.04  17. Jun CEST 2007

MANIFEST  view on Meta::CPAN

t/som.t
t/rect.t
t/hexa.t
t/torus.t
t/pods.t
lib/AI/NeuralNet/SOM.pm
lib/AI/NeuralNet/SOM/Rect.pm
lib/AI/NeuralNet/SOM/Hexa.pm
lib/AI/NeuralNet/SOM/Torus.pm
lib/AI/NeuralNet/SOM/Utils.pm
META.yml                                 Module meta-data (added by MakeMaker)

lib/AI/NeuralNet/SOM.pm  view on Meta::CPAN

                                         input_dim  => 3);
  $nn->initialize;
  $nn->train (30, 
    [ 3, 2, 4 ], 
    [ -1, -1, -1 ],
    [ 0, 4, -3]);

  my @mes = $nn->train (30, ...);      # learn about the smallest errors
                                       # during training

  print $nn->as_data;                  # dump the raw data
  print $nn->as_string;                # prepare a somehow formatted string

  use AI::NeuralNet::SOM::Torus;
  # similar to above

  use AI::NeuralNet::SOM::Hexa;
  my $nn = new AI::NeuralNet::SOM::Hexa (output_dim => 6,
                                         input_dim  => 4);
  $nn->initialize ( [ 0, 0, 0, 0 ] );  # all get this value

lib/AI/NeuralNet/SOM/Torus.pm  view on Meta::CPAN


  use AI::NeuralNet::SOM::Torus;
  my $nn = new AI::NeuralNet::SOM::Torus (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 DESCRIPTION

This SOM is very similar to that with a rectangular topology, except that the rectangle is connected
on the top edge and the bottom edge to first form a cylinder; and that cylinder is then formed into
a torus by connecting the rectangle's left and right border (L<http://en.wikipedia.org/wiki/Torus>).

=head1 INTERFACE

It exposes the same interface as the base class.

t/rect.t  view on Meta::CPAN

    foreach my $x ( 0 .. 4 ) {
	foreach my $y ( 0 .. 5 ) {
	    return 1 if AI::NeuralNet::SOM::Utils::vector_distance ($m->[$x]->[$y], $v) < 0.01;
	}
    }
    return 0;
}


    ok ($nn->as_string, 'pretty print');
    ok ($nn->as_data, 'raw format');

#    print $nn->as_string;
}

{
    my $nn = new AI::NeuralNet::SOM::Rect (output_dim => "5x6",
					   input_dim  => 3);
    $nn->initialize;

    foreach my $x (0 .. 5 -1) {

t/torus.t  view on Meta::CPAN

    foreach my $x ( 0 .. 4 ) {
	foreach my $y ( 0 .. 5 ) {
	    return 1 if AI::NeuralNet::SOM::Utils::vector_distance ($m->[$x]->[$y], $v) < 0.01;
	}
    }
    return 0;
}


    ok ($nn->as_string, 'pretty print');
    ok ($nn->as_data, 'raw format');

#    print $nn->as_string;
}

__END__

# randomized pick
    @vectors = ...;
my $get = sub {
    return @vectors [ int (rand (scalar @vectors) ) ];

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 0.590 second using v1.00-cache-2.02-grep-82fe00e-cpan-4673cadbf75 )