AI-Nerl
view release on metacpan or search on metacpan
examples/digits/deep_digits.pl view on Meta::CPAN
scale_input => 1/256,
);
$nerl->init_network(l1 => 784, l3=>10, l2=>7);#method=batch,hidden=>12345,etc
my $prev_nerl = $nerl;
my $prev_cost = 10000;
my $passes=0;
for(1..3000){
my @test = ($images(9000:9999)->sever,$y(9000:9999)->sever);
my $n = int rand(8000);
my $m = $n+499;
my @train = ($images->slice("$n:$m")->copy, $y->slice("$n:$m")->copy);
$nerl->train(@train,passes=>10);
my ($cost, $nc) = $nerl->cost( @test );
print "cost:$cost\n,num correct: $nc / 1000\n";
# $nerl->network->show_neuron(1);
$passes++;
if ($cost < $prev_cost or $passes<10){
$prev_cost = $cost;
$prev_nerl = $nerl;
} else { # use $nerl as basis for $nerl
$passes=0;
print "New layer!";
examples/digits/digits.pl view on Meta::CPAN
my $y = identity(10)->range($labels->transpose)->sever;
$y *= 2;
$y -= 1;
say 't10k data loaded';
my $nerl = AI::Nerl->new(
# type => image,dims=>[28,28],...
scale_input => 1/256,
# train_x => $images(0:99),
# train_y => $y(0:99),
# test_x => $images(8000:8999),
# test_y => $y(8000:8999),
# cv_x => $images(9000:9999),
# cv_y => $y(9000:9999),
);
$nerl->init_network(l1 => 784, l3=>10, l2=>80,alpha=>.45);#method=batch,hidden=>12345,etc
for(1..300){
my $n = int rand(8000);
my $m = $n+999;
my $ix = $images->slice("$n:$m");
lib/AI/Nerl.pm view on Meta::CPAN
use PDL;
use AI::Nerl::Network;
# ABSTRACT: Neural networks with backpropagation.
# main_module
our $VERSION = .03;
#A Nerl is a mechanism to build neural networks?
#Give it training,test, and cv data?
#it settles on a learning rate and stuff?
#or maybe it's also a language for guided training?
#or maybe a visual gui thing?
#Not exactly sure. Maybe I'm tinkering with forces better left alone.
#That's a great excuse for failing horribly.
=head1 AI::Nerl - A sort of stackable neural network builder thing.
=head1 SYNOPSIS
lib/AI/Nerl.pm view on Meta::CPAN
isa => 'Num',
default => 30,
);
has [qw/ train_x
train_y /] => (
is => 'ro',
isa => 'PDL',
required => 0, #training can be done manually.
);
has [qw/ test_x cv_x
test_y cv_y /] => (
is => 'ro',
isa => 'PDL',
required => 0,
);
has network => (
required=>0,
is => 'rw',
isa => 'AI::Nerl::Network',
);
( run in 1.533 second using v1.01-cache-2.11-cpan-5a3173703d6 )