ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> perl-AI
perl-AI
Re: AI Sales Projections?
by Ovid other posts by this author
Sep 12 2003 8:56PM messages near this date
AI::NeuralNet::Mesh vs. AI::NeuralNet::BackProp | Re: AI Sales Projections?
--- Mark Kvale <kvale@[...].edu>  wrote:
>  a) AI::NeuralNet::Mesh - trains up multi-layer perceptrons, a type of
>  feedforward neural net. It has good documentation. For your problem, I
>  would reccommend a 3 layer net, with one input, one hidden and one
>  output layer, with tanh activation fuctions.

Hi all,

Thanks to everyone for input.  I decided to start first with AI::NeuralNet::Mesh because it 
looks
easy, but so far, I can't seem to train my computer to learn binary.  Below my signoff is th
e full
program that I wrote.  Here are the results of my test run:

  Enter a four digit binary number (<ENTER>  to quit): 0001
  0 0 0 1: 9
  Enter a four digit binary number (<ENTER>  to quit): 0011
  0 0 1 1: 12
  Enter a four digit binary number (<ENTER>  to quit): 1100
  1 1 0 0: 12
  Enter a four digit binary number (<ENTER>  to quit): 1001
  1 0 0 1: 12
  Enter a four digit binary number (<ENTER>  to quit): 1111
  1 1 1 1: 16
  Enter a four digit binary number (<ENTER>  to quit): 0000
  0 0 0 0: 7

Is my problem that I have too small of a dataset from which the net can extrapolate results 
or is
it my failure to understand how the module functions?  So I have layers, nodes per layer, an
d
output nodes.  I believe "output nodes" corresponds to how many potential outputs can result
 from
one combination of inputs (each series of zeroes and ones represents one decimal number), bu
t I
don't necessarily know what the other values do.  

Can you possibly give a brief explanation?  I know I won't get exact results from a neural n
et,
but I would like results that are close.

Cheers,
Ovid

#!/usr/bin/perl
use strict;

use AI::NeuralNet::Mesh;
my $net = AI::NeuralNet::Mesh-> new(3,7,1);

if (!$net-> load('binary.mesh')) {
    $net-> learn_set([
        [qw/1 0 1 1/], [11],
        [qw/0 0 1 0/], [2 ],
        [qw/0 1 0 1/], [5 ],
        [qw/1 1 0 0/], [12],
        [qw/0 0 1 1/], [3 ],
        [qw/1 1 0 1/], [13],
        [qw/0 1 0 0/], [4 ],
        [qw/0 1 1 0/], [6 ],
        [qw/0 1 1 1/], [7 ],
        [qw/1 0 1 0/], [10],
        [qw/1 1 1 0/], [14],
        [qw/0 0 0 1/], [1 ],
        [qw/0 0 0 0/], [0 ],
        [qw/1 0 0 1/], [9 ],
    ]);
    $net-> save('binary.mesh');
}

while (my $number = prompt()) {
    printf "@$number: %d\n", $net-> run($number)->[0];
}

sub prompt {
    my $number;
    do {
        print "Enter a four digit binary number (<ENTER>  to quit): ";
        $number = <> ;
        chomp $number;
        exit unless $number;
    } until $number =~ /^[01]{4}$/;
    return [split //, $number];
}


=====
Silence is Evil            http://users.easystreet.com/ovid/philosophy/indexdecency.htm
Ovid                       http://www.perlmonks.org/index.pl?node_id=17000
Web Programming with Perl  http://users.easystreet.com/ovid/cgi_course/

__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com
Thread:
Ovid
Mark Kvale
Ala Qumsieh
Mark Kvale
Dan Von Kohorn
Ovid
Ala Qumsieh
Mark Kvale
Richard Rankin
Kevin

Privacy Policy | Email Opt-out | Feedback | Syndication
© 2004 ActiveState, a division of Sophos All rights reserved