AI-ActivationFunctions

 view release on metacpan or  search on metacpan

examples/neural_network.pl  view on Meta::CPAN

# Simple forward pass
print "Forward pass through network:\n";
foreach my $example (@training_data) {
    my $input = $example->{input};
    my $target = $example->{output}[0];
    
    # Forward pass
    my $hidden = neural_layer($input, \@weights, \@biases, \&sigmoid);
    my $prediction = $hidden->[0];
    
    # Calculate error
    my $error = $target - $prediction;
    
    printf("Input: [%d, %d] -> Prediction: %.4f (Target: %d, Error: %.4f)\n",
           $input->[0], $input->[1], $prediction, $target, $error);
}

# Backpropagation example
print "\nBackpropagation step (simplified):\n";
my $example = $training_data[1];  # [0

test_minimal.pl  view on Meta::CPAN

    print "   ✓ Módulo carregado\n";
    
    # Testa uma função
    my $test = AI::ActivationFunctions::relu(10);
    print "   ✓ relu(10) = $test\n";
    
    1;
} or do {
    print "   ✗ Erro: $@\n";
    
    # Mostra o arquivo se houver erro
    if (-f 'lib/AI/ActivationFunctions.pm') {
        print "\nConteúdo do arquivo (primeiras 20 linhas):\n";
        open my $fh, '<', 'lib/AI/ActivationFunctions.pm' or die $!;
        my $linenum = 0;
        while (<$fh>) {
            $linenum++;
            print "$linenum: $_";
            last if $linenum >= 20;
        }
        close $fh;



( run in 0.316 second using v1.01-cache-2.11-cpan-0ffa90cfd1c )