AI-ANN
view release on metacpan or search on metacpan
lib/AI/ANN.pm view on Meta::CPAN
303304305306307308309310311312313314315316317318319320321322323We 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
656667686970717273747576777879808182838485if
(
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 )