AI-NeuralNet-Hopfield
view release on metacpan or search on metacpan
lib/AI/NeuralNet/Hopfield.pm view on Meta::CPAN
my $input_matrix = &convert_array($self->matrix_rows, $self->matrix_cols, @pattern);
for (my $col = 1; $col <= ($#pattern + 1); $col++) {
my $column_matrix = &get_col($self, $col);
my $transposed_column_matrix = &transpose($column_matrix);
my $dot_product = &dot_product($input_matrix, $transposed_column_matrix);
#say $dot_product;
if ($dot_product > 0) {
$output[$col - 1] = "true";
} else {
$output[$col - 1] = "false";
}
}
return @output;
}
lib/AI/NeuralNet/Hopfield.pm view on Meta::CPAN
return $new_matrix;
}
sub print_matrix() {
my $matrix = shift;
my $rs = $matrix->{_rows};
my $cs = $matrix->{_cols};
for (my $i = 1; $i <= $rs; $i++) {
for (my $j = 1; $j <= $cs; $j++) {
say "[$i,$j]" . $matrix->get($i, $j);
}
}
}
=head1 SYNOPSIS
This is a version of a Hopfield Network implemented in Perl. Hopfield networks are sometimes called associative networks since
they associate a class pattern to each input pattern, they are tipically used for classification problems with binary pattern vectors.
=head1 SUBROUTINES/METHODS
( run in 0.981 second using v1.01-cache-2.11-cpan-5b529ec07f3 )