Grokbase Groups Perl ai March 2005
Hi Jim,

Did you get my direct email on friday?

There's a couple of problems here:

1) You have a network of 3 layers, with a single layer in each node. A
neural net works by changing the weights between arrays of nodes. Having a
single node in each layer means you have something like this:


feeding activation into the left, it will flow through to the right, but
when you adjust the weights, you only have 1 pathway to choose from, so
the network won't learn. I've posted a very simple intro to how neural
nets work at:

There's also an animated gif at that might
help to make the structure of the net clear.

2) The second problem is that you are feeding analogue numbers into the net:

You need to have a number of input units (see point 1), and translate your
data into a binary format that a neural net can understand, like:


(These are 0->0, 1->1, 2->4 & 3->9)

etc. This assumes you have 4 input & 4 output nodes (and you'll probably
need 4 hidden nodes as well), which means you can represent numbers up to

I'm not sure how well a simple backprop net will generalise x squared, it
may learn the examples you give it, but be unable to square a number it
hasn't seen before, although it might be possible to encode the data in a
way that will allow a certain amount of generalisation. I'll have to have
a think about that one and give it a try.


use strict;
use AI::NNFlex::momentum;
use AI::NNFlex::Dataset;

# Create the network

my $network = AI::NNFlex::momentum->new( learningrate=>.1,

$network->add_layer( nodes=>1,

$network->add_layer( nodes=>1,

$network->add_layer( nodes=>1,


my $dataset = AI::NNFlex::Dataset->new([

my $counter=0;
my $err = 10;
while ($err >1.001)
$err = $dataset->learn($network);

print "Epoch $counter: Error = $err\n";


foreach (@{$dataset->run($network)})
foreach (@$_){print $_}
print "\n";

Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupai @
postedMar 20, '05 at 12:43p
activeMar 20, '05 at 12:43p

1 user in discussion

Charles Colbourn: 1 post



site design / logo © 2021 Grokbase