AI-ActivationFunctions
view release on metacpan or search on metacpan
AI-ActivationFunctions-0.01/AI-ActivationFunctions-0.01/t/00-load.t view on Meta::CPAN
#!/usr/bin/perl
use strict;
use warnings;
use Test::More tests => 1;
BEGIN {
use_ok('AI::ActivationFunctions');
}
diag("Testing AI::ActivationFunctions $AI::ActivationFunctions::VERSION");
AI-ActivationFunctions-0.01/AI-ActivationFunctions-0.01/t/basic.t view on Meta::CPAN
#!/usr/bin/perl
use strict;
use warnings;
use Test::More tests => 17; # Agora 17 testes!
# Carregar e importar
use AI::ActivationFunctions qw(relu prelu leaky_relu sigmoid tanh softmax);
# Teste 1: ReLU
is(relu(5), 5, 'relu(5) = 5');
is(relu(-5), 0, 'relu(-5) = 0');
is(relu(0), 0, 'relu(0) = 0');
# Teste 2: PReLU
AI-ActivationFunctions-0.01/AI-ActivationFunctions-0.01/t/pdl.t view on Meta::CPAN
BEGIN {
eval {
require PDL;
1;
} or do {
plan skip_all => 'PDL não está instalado';
exit 0;
};
}
# Continuar com os testes
plan tests => 1;
# Testar se podemos usar PDL com nosso módulo
use_ok('AI::ActivationFunctions');
# Nota: Nosso módulo atual não tem suporte a PDL,
# então apenas testamos o carregamento
done_testing();
lib/AI/ActivationFunctions/PDL.pm
Makefile.PL
MANIFEST
META.json
META.yml
README.md
t/00-load.t
t/basic.t
t/extended.t
t/pdl.t
test_all.sh
test_minimal.pl
test_quick.pl
create_structure.sh view on Meta::CPAN
# save como create_structure.sh
# Criar diretórios
#mkdir -p AI-ActivationFunctions-0.01/lib/AI/ActivationFunctions
#mkdir -p AI-ActivationFunctions-0.01/t
#mkdir -p AI-ActivationFunctions-0.01/examples
# Mover para o diretório
#cd AI-ActivationFunctions-0.01
# Criar Makefile.PL (simplificado para teste)
cat > Makefile.PL << 'EOF'
use 5.010001;
use ExtUtils::MakeMaker;
WriteMakefile(
NAME => 'AI::ActivationFunctions',
VERSION_FROM => 'lib/AI/ActivationFunctions.pm',
ABSTRACT_FROM => 'lib/AI/ActivationFunctions.pm',
AUTHOR => 'Ulisses Manzo Castello <umcastello@gmail.com>',
LICENSE => 'perl_5',
create_structure.sh view on Meta::CPAN
'Carp' => 0,
},
TEST_REQUIRES => {
'Test::More' => 0,
},
META_MERGE => {
'meta-spec' => { version => 2 },
resources => {
repository => {
type => 'git',
url => 'https://github.com/test/ai-activationfunctions.git',
},
},
},
);
EOF
echo "Estrutura criada! Agora copie os arquivos .pm e .t para os diretórios."
echo "Use os códigos que eu forneci anteriormente."
t/00-load.t view on Meta::CPAN
#!/usr/bin/perl
use strict;
use warnings;
use Test::More tests => 1;
BEGIN {
use_ok('AI::ActivationFunctions');
}
diag("Testing AI::ActivationFunctions $AI::ActivationFunctions::VERSION");
#!/usr/bin/perl
use strict;
use warnings;
use Test::More tests => 17; # Agora 17 testes!
# Carregar e importar
use AI::ActivationFunctions qw(relu prelu leaky_relu sigmoid tanh softmax);
# Teste 1: ReLU
is(relu(5), 5, 'relu(5) = 5');
is(relu(-5), 0, 'relu(-5) = 0');
is(relu(0), 0, 'relu(0) = 0');
# Teste 2: PReLU
t/extended.t view on Meta::CPAN
#!/usr/bin/perl
use strict;
use warnings;
use Test::More tests => 8; # Plan primeiro
# Importar funções especÃficas
use AI::ActivationFunctions qw(elu swish gelu relu_derivative sigmoid_derivative);
# Teste ELU
my $elu_pos = elu(1, 1);
is(sprintf("%.1f", $elu_pos), "1.0", 'elu(1,1) = 1.0');
my $elu_neg = elu(-1, 1);
ok($elu_neg > -0.64 && $elu_neg < -0.63, "elu(-1,1) â -0.632 ($elu_neg)");
BEGIN {
eval {
require PDL;
1;
} or do {
plan skip_all => 'PDL não está instalado';
exit 0;
};
}
# Continuar com os testes
plan tests => 1;
# Testar se podemos usar PDL com nosso módulo
use_ok('AI::ActivationFunctions');
# Nota: Nosso módulo atual não tem suporte a PDL,
# então apenas testamos o carregamento
done_testing();
test_all.sh view on Meta::CPAN
#mkdir -p AI-ActivationFunctions-simple/lib/AI
#mkdir AI-ActivationFunctions-simple/t
#mkdir AI-ActivationFunctions-simple/examples
#cd AI-ActivationFunctions-simple
# 2. Copie os arquivos acima para seus respectivos diretórios
# 3. Teste
perl -Ilib -e "use AI::ActivationFunctions; print 'Carregou!\\n';"
# 4. Execute o teste rápido
perl test_quick.pl
# 5. Execute os testes formais
prove -Ilib t/
# 6. Execute o exemplo
perl examples/simple.pl
test_minimal.pl view on Meta::CPAN
my ($x) = @_;
my $e2x = exp(2 * $x);
return ($e2x - 1) / ($e2x + 1);
}
# Teste
print " relu(5) = " . relu(5) . " (esperado: 5)\n";
print " relu(-3) = " . relu(-3) . " (esperado: 0)\n";
print " tanh(0) = " . tanh_simple(0) . " (esperado: ~0)\n";
print "\n2. Agora testando o módulo...\n";
# Tente carregar o módulo
eval {
# Adiciona lib ao @INC
unshift @INC, 'lib';
require AI::ActivationFunctions;
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;
( run in 2.251 seconds using v1.01-cache-2.11-cpan-62a16548d74 )