line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package AI::NeuralNet::FastSOM; |
2
|
|
|
|
|
|
|
|
3
|
11
|
|
|
11
|
|
15892
|
use strict; |
|
11
|
|
|
|
|
16
|
|
|
11
|
|
|
|
|
280
|
|
4
|
11
|
|
|
11
|
|
38
|
use warnings; |
|
11
|
|
|
|
|
12
|
|
|
11
|
|
|
|
|
240
|
|
5
|
11
|
|
|
11
|
|
38
|
use XSLoader; |
|
11
|
|
|
|
|
15
|
|
|
11
|
|
|
|
|
2507
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.17'; |
8
|
|
|
|
|
|
|
|
9
|
0
|
|
|
0
|
0
|
0
|
sub new { die 'Dont use this class directly' } |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub label { |
12
|
3
|
|
|
3
|
0
|
482
|
my ($self, $x, $y, $l) = @_; |
13
|
|
|
|
|
|
|
return defined $l |
14
|
|
|
|
|
|
|
? $self->{labels}->[$x]->[$y] = $l |
15
|
3
|
100
|
|
|
|
27
|
: $self->{labels}->[$x]->[$y]; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub value { |
19
|
90
|
|
|
90
|
0
|
19644
|
my ($self, $x, $y, $v) = @_; |
20
|
|
|
|
|
|
|
return defined $v |
21
|
|
|
|
|
|
|
? $self->{map}[$x][$y] = $v |
22
|
90
|
100
|
|
|
|
1350
|
: $self->{map}[$x][$y]; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub mean_error { |
26
|
162
|
|
|
162
|
0
|
49151
|
my $self = shift; |
27
|
162
|
|
|
|
|
136
|
my $error = 0; |
28
|
486
|
|
|
|
|
580
|
map { $error += $_ } # then add them all up |
29
|
162
|
|
|
|
|
204
|
map { ( $self->bmu($_) )[2] } # then find the distance |
|
486
|
|
|
|
|
2239
|
|
30
|
|
|
|
|
|
|
@_; # take all data vectors |
31
|
162
|
|
|
|
|
372
|
return ($error / scalar @_); # return the mean value |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
XSLoader::load(__PACKAGE__); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
1; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
__END__ |