| 1 | package AI::NeuralNet::Kohonen::Input; | ||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use vars qw/$VERSION $TRACE/; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 4 | 1 | $VERSION = 0.1; | |||||||||||||||||||||||||||||||||
| 5 | 1 | $TRACE = 1; | |||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||
| 7 | =head1 NAME | ||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||
| 9 | AI::NeuralNet::Kohonen::Input - an input vector for AI::NeuralNet::Kohonen | ||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||
| 11 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||
| 13 | Implimentation of an input vector for the Kohonen SOM: | ||||||||||||||||||||||||||||||||||
| 14 | L<AI::NeuralNet::Kohonen>. | ||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||
| 16 | =cut | ||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||
| 18 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 19 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 20 | 1 | ▶ | use Carp qw/cluck carp confess croak/; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||
| 22 | =head1 CONSTRUCTOR (new) | ||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||
| 24 | =over 4 | ||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||
| 26 | =item dim | ||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||
| 28 | Scalar - the number of dimensions of this input vector. | ||||||||||||||||||||||||||||||||||
| 29 | Need not be supplied if C<values> is supplied. | ||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||
| 31 | =item values | ||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||
| 33 | Reference to an array containing the values for this | ||||||||||||||||||||||||||||||||||
| 34 | input vector. There should be one entry for each dimension, | ||||||||||||||||||||||||||||||||||
| 35 | with unknown values having the value C<undef>. | ||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||
| 37 | =item class | ||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||
| 39 | Optional class label string for this input vector. | ||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||
| 41 | =back | ||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||
| 43 | =cut | ||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||
| 45 | 9 | ▶ | sub new { | ||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=8 SCAR=28.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 46 | 9 | my $class = shift; | |||||||||||||||||||||||||||||||||
| 47 | 9 | my %args = @_; | |||||||||||||||||||||||||||||||||
| 48 | 9 | my $self = bless \%args,$class; | |||||||||||||||||||||||||||||||||
| 49 | 9 | ▶ | if (not defined $self->{values}){ | ||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||
| 50 | 0 | ▶ | if (not defined $self->{dim}){ | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 51 | 0 | cluck "No {dim} or {weight}!"; | |||||||||||||||||||||||||||||||||
| 52 | 0 | return undef; | |||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||
| 54 | 0 | $self->{values} = []; | |||||||||||||||||||||||||||||||||
| 55 | } elsif (not ref $self->{values}){ | ||||||||||||||||||||||||||||||||||
| 56 | 0 | cluck "{values} not supplied!"; | |||||||||||||||||||||||||||||||||
| 57 | 0 | return undef; | |||||||||||||||||||||||||||||||||
| 58 | } elsif (ref $self->{values} ne 'ARRAY') { | ||||||||||||||||||||||||||||||||||
| 59 | 0 | cluck "{values} should be an array reference, not $self->{values}!"; | |||||||||||||||||||||||||||||||||
| 60 | 0 | return undef; | |||||||||||||||||||||||||||||||||
| 61 | ▶ | } elsif (defined $self->{dim} and defined $self->{values} | |||||||||||||||||||||||||||||||||
|
Condition66%4/6
defined $self->{"dim"} and defined $self->{"values"} and $self->{"dim"} ne $#{$$self{"values"};}
defined $self->{"dim"} and defined $self->{"values"}
MC/DC0%0/3
defined $self->{"dim"} and defined $self->{"values"} and $self->{"dim"} ne $#{$$self{"values"};}
defined $self->{"dim"}
defined $self->{"values"}
$self->{"dim"} ne $#{$$self{"values"};}
Truth table50%2/4
A and B and C
A= defined $self->{"dim"}B= defined $self->{"values"}C= $self->{"dim"} ne $#{$$self{"values"};}
| |||||||||||||||||||||||||||||||||||
| 62 | 4 | and $self->{dim} ne $#{$self->{values}}){ | |||||||||||||||||||||||||||||||||
| 63 | 0 | cluck "{values} and {dim} do not match!"; | |||||||||||||||||||||||||||||||||
| 64 | 0 | return undef; | |||||||||||||||||||||||||||||||||
| 65 | } else { | ||||||||||||||||||||||||||||||||||
| 66 | 9 | $self->{dim} = $#{$self->{values}}; | |||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||
| 68 | 9 | return $self; | |||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||
| 73 | 1 | 1; | |||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||
| 75 | __END__ | ||||||||||||||||||||||||||||||||||