view release on metacpan or search on metacpan
ANN_specification view on Meta::CPAN
ANN
implements an artificial neural network
from caller, $network = new ANN( $inputcount, [{ iamanoutput => 0, inputs => {$inputid => $weight, ...}, neurons => {$neuronid => $weight}}, ...])
from caller, $network->execute( [$input0, $input1, ...] ) runs the network with the provided inputs and returns the outputs as an arrayref
from caller, $network->get_state() returns three arrayrefs, [$input0, ...], [$neuron0, ...], [$output0, ...]
from caller, $network->get_input_count() returns the number of inputs
from caller, $network->get_internals() returns the original arrayref format - for the evolver, perhaps
from caller, $network->readable() returns a text-based human-readable and diffable description of the network:
Neuron 0:
Input from input 0, weight is 0.34232
Input from input 1, weight is -0.21231
Input from neuron 21, weight is 0.3213
This neuron is a network output
it should be noted that the network need not be feed-forward. ANN should use $self->{'network'}->ready() to determine if input conditions are satisfied. If it is impossible to complete the run by using ready(), then the network should store a list o...
ANN::Neuron
implements an individual neuron from the neural network
from ann, $self->{'network'}->[$n]->{'object'} = new ANN::Neuron( $thisid, {$inputid => $weight, ...}, {$neuronid => $weight})
from ann, $self->{'network'}->[$n]->{'object'}->ready( [$input0, $input1, ...], {$neuronid => $neuronvalue, ...} ) returns 1 if all inputs are available, 0 otherwise
from ann, $self->{'network'}->[$n]->{'object'}->execute( [$input0, $input1, ...], {$neuronid => $neuronvalue, ...} ) returns the output value of the neuron
in addition, get_inputs and get_neurons are available. There return the respective original hashrefs.
ANN::Evolver
evolves the ann
from caller, $handofgod = new ANN::Evolver({$mutationchance, $mutationamount, $addlinkchance, $killlinkchance, $subcrossoverchance}) add should be zero if you want to preserve feed-forwardness
from caller, $handofgod->crossover($network1, $network2) returns $network3, which inherits 50% of each parent's traits. Each neuron has $subcrossoverchance to inherit 50% of its traits from each parent.
from caller, $handofgod->mutate($network3) introduces some random mutations into neuron weights. Has a $mutationchance to change each weight by up to $mutationamount, a $addlinkchance to change an input from zero to up to $mutationamount, and a $kil...
ANN::SimWorld
uses an ANN object to attempt to survive in a virtual world, which must be defined by the caller
from caller, $world = new ANN::SimWorld( //stuff here )
from caller, $world->($network) returns a fitness variable
Copyright (C) 2011 by Daniel Collins
This library is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Revision History for ANN
0.008 2011-06-13 06:52:38 UTC
Add support for an Inline::C version of AI::ANN::Neuron::Execute.
This is the default.
Fix a few extra errors because of uninitialized values being sent to
the C code. If you're using the inline::c stuff, be careful that
you don't skip any necessary inputs.
0.007 2011-06-12 04:44:46 UTC
Add backprop, not tested.
Evolver now allows you to pass a coderef for mutation_amount. It
will be evaluated with no arguments. If you pass a number instead,
it will be coerced into a uniform random value up to +/- your value.
Change a few things from hashrefs to arrayrefs internally. Fully
back-compatibile, but I hope this will speed up a few things.
Fix dependencies.
0.006 2011-06-01 16:08:04 UTC
Remove dependency on perl 5.14, because apparently no one has that
installed yet. Get with the times, people! (Debian is still on 5.10)
Add mutate_gaussian to the methods available in the evolver, and
allow the population of the eta_ values in AI::ANN.
Add a sternly worded comment to the evolver warning against the use
of crossover.
0.005 2011-05-31 20:18:02 UTC
Convert to use Moose. I'm told that this is better. There are a few
neat things (not having to write accessors, and apparently
inheritance just works, I'll find out about that soon enough...)
but overall I really don't see the point. Default values, type
constraints, I had all that anyway. Meh.
Add some words about what the point of this module is.
0.004 2011-05-31 02:35:26 UTC
Minor calling changes that I need to commit so I can test them with
another module.
0.003 2011-05-31 01:09:32 UTC
Minor. Correct the perl version requirement.
0.002 2011-05-31 01:04:53 UTC
Make many obvious (to a computer, I hope) references to the fact
that this requires perl 5.14, to prevent the bloody annoying
CPAN Testers emails. Note that I chose to do this rather than
make the module compatible with earlier versions.
Add two parameters for min and max neuron output values, default to
0 and 1. Conveniently, forget to actually implement that.
Less conveniently, remember to implement the above.
While implementing the above, also implement an activation function
in the form of a coderef passed to the AI::ANN constructor.
Add the Evolver module, and tests for it. Ensure that the AI::ANN
objects that Evolver returns have the same parameters as did the
original.
Chase down a few bugs caused by a combination of evil references
and me changing the structure of my objects halfway through coding.
Yell at myself a little bit for taunting the ghost of the (not yet
dead) Larry Wall, by claiming that I was 'halfway through coding'.
0.001 2011-05-27 03:04:06 UTC
Initial release. ANN and ANN::Neuron working, basic test suite and
documentation.
---
abstract: "an artificial neural network simulator\r"
author:
- 'Dan Collins <DCOLLINS@cpan.org>'
build_requires: {}
configure_requires:
ExtUtils::MakeMaker: 6.30
dynamic_config: 0
generated_by: 'Dist::Zilla version 4.200006, CPAN::Meta::Converter version 2.110930'
license: gpl
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: 1.4
name: AI-ANN
requires:
Inline::C: 0
Math::Libm: 0
Moose: 2.00
Storable: 0
version: 0.008
Makefile.PL view on Meta::CPAN
use strict;
use warnings;
use ExtUtils::MakeMaker 6.30;
my %WriteMakefileArgs = (
'ABSTRACT' => 'an artificial neural network simulator
',
'AUTHOR' => 'Dan Collins <DCOLLINS@cpan.org>',
'BUILD_REQUIRES' => {},
'CONFIGURE_REQUIRES' => {
'ExtUtils::MakeMaker' => '6.30'
},
'DISTNAME' => 'AI-ANN',
'EXE_FILES' => [],
'LICENSE' => 'gpl',
'NAME' => 'AI::ANN',
'PREREQ_PM' => {
'Inline::C' => '0',
'Math::Libm' => '0',
'Moose' => '2.00',
'Storable' => '0'
},
'VERSION' => '0.008',
'test' => {
'TESTS' => 't/*.t'
}
);
unless ( eval { ExtUtils::MakeMaker->VERSION(6.56) } ) {
my $br = delete $WriteMakefileArgs{BUILD_REQUIRES};
my $pp = $WriteMakefileArgs{PREREQ_PM};
for my $mod ( keys %$br ) {
if ( exists $pp->{$mod} ) {
$pp->{$mod} = $br->{$mod} if $br->{$mod} > $pp->{$mod};
}
else {
$pp->{$mod} = $br->{$mod};
}
}
}
delete $WriteMakefileArgs{CONFIGURE_REQUIRES}
unless eval { ExtUtils::MakeMaker->VERSION(6.52) };
WriteMakefile(%WriteMakefileArgs);
This archive contains the distribution AI-ANN,
version 0.008:
an artificial neural network simulator
This software is Copyright (c) 2011 by Dan Collins.
This is free software, licensed under:
The GNU General Public License, Version 3, June 2007
_Inline/build/AI/ANN/Neuron_6185/Makefile view on Meta::CPAN
UNINSTALL = $(ABSPERLRUN) -MExtUtils::Command::MM -e 'uninstall' --
WARN_IF_OLD_PACKLIST = $(ABSPERLRUN) -MExtUtils::Command::MM -e 'warn_if_old_packlist' --
MACROSTART =
MACROEND =
USEMAKEFILE = -f
FIXIN = $(ABSPERLRUN) -MExtUtils::MY -e 'MY->fixin(shift)' --
# --- MakeMaker makemakerdflt section:
makemakerdflt : all
$(NOECHO) $(NOOP)
# --- MakeMaker dist section:
TAR = tar
TARFLAGS = cvf
ZIP = zip
ZIPFLAGS = -r
COMPRESS = gzip --best
SUFFIX = .gz
SHAR = shar
_Inline/build/AI/ANN/Neuron_6185/Neuron_6185.xs view on Meta::CPAN
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#include "INLINE.h"
double _execute_internals ( AV* inputs, AV* neurons, AV* inputweights, AV* neuronweights ) {
double output = 0.0;
int i;
int v1 = av_len(inputweights);
int v2 = av_len(inputs);
if (v2 < v1) {
v1 = v2;
}
if (v1 >= 0) {
for (i=0; i<=v1; i++) {
SV** val = av_fetch(inputs, i, 0);
SV** weight = av_fetch(inputweights, i, 0);
output += SvNV(*val) * SvNV(*weight);
}
}
int v1 = av_len(neuronweights);
int v2 = av_len(neurons);
if (v2 < v1) {
v1 = v2;
}
if (v1 >= 0) {
for (i=0; i<=v1; i++) {
SV** val = av_fetch(neurons, i, 0);
SV** weight = av_fetch(neuronweights, i, 0);
output += SvNV(*val) * SvNV(*weight);
}
}
return output;
}
MODULE = AI::ANN::Neuron_6185 PACKAGE = AI::ANN::Neuron
PROTOTYPES: DISABLE
double
_execute_internals (inputs, neurons, inputweights, neuronweights)
AV * inputs
AV * neurons
AV * inputweights
AV * neuronweights
_Inline/config-i686-linux-gnu-thread-multi-5.010001 view on Meta::CPAN
version : 0.48
languages : %
C : C
Foo : Foo
foo : Foo
types : %
C : compiled
Foo : interpreted
modules : %
C : Inline::C
Foo : Inline::Foo
suffixes : %
C : so
Foo : foo
_Inline/lib/auto/AI/ANN/Neuron_1390/Neuron_1390.inl view on Meta::CPAN
md5 : 139035d45e72a424eed54330b28d6a1c
name : AI::ANN::Neuron_1390
version : ""
language : C
language_id : C
installed : 0
date_compiled : Mon Jun 13 01:45:58 2011
inline_version : 0.48
ILSM : %
module : Inline::C
suffix : so
type : compiled
Config : %
apiversion : ?
archname : i686-linux-gnu-thread-multi
cc : cc
ccflags : -D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
ld : cc
osname : linux
osvers : 2.6.24-28-server
so : so
version : 5.10.1
_Inline/lib/auto/AI/ANN/Neuron_510f/Neuron_510f.inl view on Meta::CPAN
md5 : 510f5931670e4899296d14d49d9931f2
name : AI::ANN::Neuron_510f
version : ""
language : C
language_id : C
installed : 0
date_compiled : Mon Jun 13 01:57:19 2011
inline_version : 0.48
ILSM : %
module : Inline::C
suffix : so
type : compiled
Config : %
apiversion : ?
archname : i686-linux-gnu-thread-multi
cc : cc
ccflags : -D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
ld : cc
osname : linux
osvers : 2.6.24-28-server
so : so
version : 5.10.1
_Inline/lib/auto/AI/ANN/Neuron_69ce/Neuron_69ce.inl view on Meta::CPAN
md5 : 69ce4b9d722e15b3a839f0d4631825a7
name : AI::ANN::Neuron_69ce
version : ""
language : C
language_id : C
installed : 0
date_compiled : Mon Jun 13 01:53:41 2011
inline_version : 0.48
ILSM : %
module : Inline::C
suffix : so
type : compiled
Config : %
apiversion : ?
archname : i686-linux-gnu-thread-multi
cc : cc
ccflags : -D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
ld : cc
osname : linux
osvers : 2.6.24-28-server
so : so
version : 5.10.1
_Inline/lib/auto/AI/ANN/Neuron_7dc5/Neuron_7dc5.inl view on Meta::CPAN
md5 : 7dc5028a840e627aaa5244b4d7cb68b8
name : AI::ANN::Neuron_7dc5
version : ""
language : C
language_id : C
installed : 0
date_compiled : Mon Jun 13 02:22:47 2011
inline_version : 0.48
ILSM : %
module : Inline::C
suffix : so
type : compiled
Config : %
apiversion : ?
archname : i686-linux-gnu-thread-multi
cc : cc
ccflags : -D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
ld : cc
osname : linux
osvers : 2.6.24-28-server
so : so
version : 5.10.1
_Inline/lib/auto/AI/ANN/Neuron_930c/Neuron_930c.inl view on Meta::CPAN
md5 : 930c14642ed8afd4a59d21b9067ebfe3
name : AI::ANN::Neuron_930c
version : ""
language : C
language_id : C
installed : 0
date_compiled : Mon Jun 13 02:23:28 2011
inline_version : 0.48
ILSM : %
module : Inline::C
suffix : so
type : compiled
Config : %
apiversion : ?
archname : i686-linux-gnu-thread-multi
cc : cc
ccflags : -D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
ld : cc
osname : linux
osvers : 2.6.24-28-server
so : so
version : 5.10.1
_Inline/lib/auto/AI/ANN/Neuron_e488/Neuron_e488.inl view on Meta::CPAN
md5 : e488f899824a2ca8dc62fa5a1bedc526
name : AI::ANN::Neuron_e488
version : ""
language : C
language_id : C
installed : 0
date_compiled : Mon Jun 13 02:41:46 2011
inline_version : 0.48
ILSM : %
module : Inline::C
suffix : so
type : compiled
Config : %
apiversion : ?
archname : i686-linux-gnu-thread-multi
cc : cc
ccflags : -D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
ld : cc
osname : linux
osvers : 2.6.24-28-server
so : so
version : 5.10.1
_Inline/lib/auto/AI/ANN/Neuron_f333/Neuron_f333.inl view on Meta::CPAN
md5 : f333b8b2ada41a629969e0bede6a740b
name : AI::ANN::Neuron_f333
version : ""
language : C
language_id : C
installed : 0
date_compiled : Mon Jun 13 00:40:28 2011
inline_version : 0.48
ILSM : %
module : Inline::C
suffix : so
type : compiled
Config : %
apiversion : ?
archname : i686-linux-gnu-thread-multi
cc : cc
ccflags : -D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
ld : cc
osname : linux
osvers : 2.6.24-28-server
so : so
version : 5.10.1
examples/_Inline/build/benchmark_pl_03a5/Makefile view on Meta::CPAN
UNINSTALL = $(ABSPERLRUN) -MExtUtils::Command::MM -e 'uninstall' --
WARN_IF_OLD_PACKLIST = $(ABSPERLRUN) -MExtUtils::Command::MM -e 'warn_if_old_packlist' --
MACROSTART =
MACROEND =
USEMAKEFILE = -f
FIXIN = $(ABSPERLRUN) -MExtUtils::MY -e 'MY->fixin(shift)' --
# --- MakeMaker makemakerdflt section:
makemakerdflt : all
$(NOECHO) $(NOOP)
# --- MakeMaker dist section:
TAR = tar
TARFLAGS = cvf
ZIP = zip
ZIPFLAGS = -r
COMPRESS = gzip --best
SUFFIX = .gz
SHAR = shar
examples/_Inline/build/benchmark_pl_03a5/benchmark_pl_03a5.xs view on Meta::CPAN
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#include "INLINE.h"
#include <math.h>
double afunc[4001];
double dafunc[4001];
void generate_globals() {
double i;
for (i=0;i<=4000;i++) {
afunc[i] = 2 * (erf(i/1000.0-2));
dafunc[i] = 4 / sqrt(M_PI) * exp(-1 * ((i/1000.0-2) ** 2));
}
}
double afunc_c (float input) {
return afunc[(int) floor((input)*1000)];
}
double dafunc_c (float input) {
return dafunc[(int) floor((input)*1000)];
}
MODULE = benchmark_pl_03a5 PACKAGE = main
PROTOTYPES: DISABLE
void
generate_globals ()
PREINIT:
I32* temp;
PPCODE:
temp = PL_markstack_ptr++;
generate_globals();
if (PL_markstack_ptr != temp) {
/* truly void, because dXSARGS not invoked */
PL_markstack_ptr = temp;
XSRETURN_EMPTY; /* return empty stack */
}
/* must have used dXSARGS; list context implied */
return; /* assume stack size is correct */
double
afunc_c (input)
float input
double
dafunc_c (input)
float input
examples/_Inline/build/benchmark_pl_3d06/Makefile view on Meta::CPAN
UNINSTALL = $(ABSPERLRUN) -MExtUtils::Command::MM -e 'uninstall' --
WARN_IF_OLD_PACKLIST = $(ABSPERLRUN) -MExtUtils::Command::MM -e 'warn_if_old_packlist' --
MACROSTART =
MACROEND =
USEMAKEFILE = -f
FIXIN = $(ABSPERLRUN) -MExtUtils::MY -e 'MY->fixin(shift)' --
# --- MakeMaker makemakerdflt section:
makemakerdflt : all
$(NOECHO) $(NOOP)
# --- MakeMaker dist section:
TAR = tar
TARFLAGS = cvf
ZIP = zip
ZIPFLAGS = -r
COMPRESS = gzip --best
SUFFIX = .gz
SHAR = shar
examples/_Inline/build/benchmark_pl_3d06/benchmark_pl_3d06.xs view on Meta::CPAN
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#include "INLINE.h"
#include <math.h>
double afunc[4001];
double dafunc[4001];
void generate_globals() {
int i;
for (i=0;i<=4000;i++) {
afunc[i] = 2 * (erf(i/1000.0-2));
dafunc[i] = 4 / sqrt(M_PI) * exp(-1 * ((i/1000.0-2) ** 2));
}
}
double afunc_c (float input) {
return afunc[(int) floor((input)*1000)];
}
double dafunc_c (float input) {
return dafunc[(int) floor((input)*1000)];
}
MODULE = benchmark_pl_3d06 PACKAGE = main
PROTOTYPES: DISABLE
void
generate_globals ()
PREINIT:
I32* temp;
PPCODE:
temp = PL_markstack_ptr++;
generate_globals();
if (PL_markstack_ptr != temp) {
/* truly void, because dXSARGS not invoked */
PL_markstack_ptr = temp;
XSRETURN_EMPTY; /* return empty stack */
}
/* must have used dXSARGS; list context implied */
return; /* assume stack size is correct */
double
afunc_c (input)
float input
double
dafunc_c (input)
float input
view all matches for this distributionview release on metacpan - search on metacpan