line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package AI::NeuralNet::Kohonen::Input;
|
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
6
|
use vars qw/$VERSION $TRACE/;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
81
|
|
4
|
|
|
|
|
|
|
$VERSION = 0.1;
|
5
|
|
|
|
|
|
|
$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.
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=cut
|
17
|
|
|
|
|
|
|
|
18
|
1
|
|
|
1
|
|
5
|
use strict;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
19
|
1
|
|
|
1
|
|
5
|
use warnings;
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
56
|
|
20
|
1
|
|
|
1
|
|
5
|
use Carp qw/cluck carp confess croak/;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
311
|
|
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 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.
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=item class
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
Optional class label string for this input vector.
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=back
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=cut
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub new {
|
46
|
9
|
|
|
9
|
0
|
977
|
my $class = shift;
|
47
|
9
|
|
|
|
|
29
|
my %args = @_;
|
48
|
9
|
|
|
|
|
35
|
my $self = bless \%args,$class;
|
49
|
9
|
50
|
66
|
|
|
94
|
if (not defined $self->{values}){
|
|
|
50
|
66
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
50
|
0
|
0
|
|
|
|
0
|
if (not defined $self->{dim}){
|
51
|
0
|
|
|
|
|
0
|
cluck "No {dim} or {weight}!";
|
52
|
0
|
|
|
|
|
0
|
return undef;
|
53
|
|
|
|
|
|
|
}
|
54
|
0
|
|
|
|
|
0
|
$self->{values} = [];
|
55
|
|
|
|
|
|
|
} elsif (not ref $self->{values}){
|
56
|
0
|
|
|
|
|
0
|
cluck "{values} not supplied!";
|
57
|
0
|
|
|
|
|
0
|
return undef;
|
58
|
4
|
|
|
|
|
79
|
} elsif (ref $self->{values} ne 'ARRAY') {
|
59
|
0
|
|
|
|
|
0
|
cluck "{values} should be an array reference, not $self->{values}!";
|
60
|
0
|
|
|
|
|
0
|
return undef;
|
61
|
|
|
|
|
|
|
} elsif (defined $self->{dim} and defined $self->{values}
|
62
|
|
|
|
|
|
|
and $self->{dim} ne $#{$self->{values}}){
|
63
|
0
|
|
|
|
|
0
|
cluck "{values} and {dim} do not match!";
|
64
|
0
|
|
|
|
|
0
|
return undef;
|
65
|
|
|
|
|
|
|
} else {
|
66
|
9
|
|
|
|
|
11
|
$self->{dim} = $#{$self->{values}};
|
|
9
|
|
|
|
|
27
|
|
67
|
|
|
|
|
|
|
}
|
68
|
9
|
|
|
|
|
34
|
return $self;
|
69
|
|
|
|
|
|
|
}
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
1;
|
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
__END__
|