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