AI-ANN

 view release on metacpan or  search on metacpan

lib/AI/ANN.pm  view on Meta::CPAN

303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
We store the current state of the network in two places - once in the object,
for persistence, and once in $neurons, for simplicity. This might be wrong,
but I couldn't think of a better way.
 
=head2 get_state
 
$network->get_state()
 
Returns three arrayrefs, [$input0, ...], [$neuron0, ...], [$output0, ...],
corresponding to the data from the last call to execute().
Intended primarily to assist with debugging.
 
=head2 get_internals
 
$network->get_internals()
 
Returns the weights in a not-human-consumable format.
 
=head2 readable
 
$network->readable()

lib/AI/ANN/Evolver.pm  view on Meta::CPAN

65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
if (rand() < $self->{'sub_crossover_chance'}) {
        $networkdata3->[$i] = { 'inputs' => [], 'neurons' => [] };
        $networkdata3->[$i]->{'iamanoutput'} =
                $networkdata1->[$i]->{'iamanoutput'};
        for (my $j = 0; $j < $inputcount; $j++) {
                $networkdata3->[$i]->{'inputs'}->[$j] =
                        (rand() > 0.5) ?
                        $networkdata1->[$i]->{'inputs'}->[$j] :
                        $networkdata2->[$i]->{'inputs'}->[$j];
                # Note to self: Don't get any silly ideas about dclone()ing
                # these, that's a good way to waste half an hour debugging.
        }
        for (my $j = 0; $j <= $neuroncount; $j++) {
                $networkdata3->[$i]->{'neurons'}->[$j] =
                        (rand() > 0.5) ?
                        $networkdata1->[$i]->{'neurons'}->[$j] :
                        $networkdata2->[$i]->{'neurons'}->[$j];
        }
} else {
        $networkdata3->[$i] = dclone(
                (rand() > 0.5) ?



( run in 0.900 second using v1.01-cache-2.11-cpan-3cd7ad12f66 )