Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re^4: AI::NNEasy to setup fast a Neural Network using just Perl and XS.

by gmpassos (Priest)
on Jan 16, 2005 at 15:30 UTC ( #422624=note: print w/replies, xml ) Need Help??

in reply to Re^3: AI::NNEasy to setup fast a Neural Network using just Perl and XS.
in thread AI::NNEasy to setup fast a Neural Network using just Perl and XS.

XS is like another mini language. First you need a C compiler, actually you need the same compiler used to compile your Perl. So, on Linux is easy since is always with GCC, but on Win32 you will need Microsoft Visual C++ 6+ (not free) if you got Perl from Active State, or MingW, that is GCC for Win32.

Than you need to learn how Perl works with C and the resources for that (perlapi). So, take a look in the docs: perlapi, perlguts, perlxstut. All of that you can find better at

If you already know C, I think that the best way to you make XS functions with Perl is getting as examaple the sub{C} methods that you can find in the sources of AI::NNEasy. Because this functions have a Perl and a C version, so you can compare them and understand better what the C macros does. Also the Class::HPLOO syntax is easy like sugar, since you only need to write the function, all the rest Class::HPLOO will write for you, converting to Inline::C, than Inline will convert to XS, and from XS is with Perl. So, the code below is 100% complete, you just need to have a C compiler well installed:

use Class::HPLOO ; class Foo { sub[C] int add( int x , int y ) { int ret = x + y ; return ret ; } }
Now you just need to run the code above, and the rest is automatically.

Other thing, your module is inside AI::NNEasy starting from the class AI::NNEasy::NN. So, if you move this class (and the sub classes sinde AI::NNEasy::NN::*) to your project you will have your modules with the resources that I have added to it. I let it separated to be more easy to you to get back the work that I did, so be free to use it. ;-P

Graciliano M. P.
"Creativity is the expression of liberty".

  • Comment on Re^4: AI::NNEasy to setup fast a Neural Network using just Perl and XS.
  • Download Code

Replies are listed 'Best First'.
Re^5: AI::NNEasy to setup fast a Neural Network using just Perl and XS.
by g0n (Priest) on Jan 16, 2005 at 18:59 UTC
    Thanks for that.

    It'll take a bit of time to explore this. I'm not sure I want to use HPLoo, since I intended NNFlex to be usable as a fairly simple teaching framework. The XS & HPLoo code is quite a bit more complex than the pure perl!

      "...fairly simple teaching framework."

      Yes, is much more faster to code in pure Perl, specially if your main purpose is to make a flexible NN. But I saw that even for simple problems a NN needs speed, since if we build wrong the NN configurations for the target problem it will use a lot of CPU and time in the learning fase. Even a simple "tic tac toe" game, that I have used as a 1st real test for NNEasy, uses a lot of time to learn a big amount of inputs, so I started to add the XS support what make possible to learn fast the inputs and really play. In other words, NN always use a lot of CPU, so we can't run way from the C codes. About Class::HPLOO, for me is the fastest way to add the C support for the functions that really need that.

      Graciliano M. P.
      "Creativity is the expression of liberty".

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://422624]
[Corion]: Hi holli ;)
[Corion]: In a way, it's sad that Firefox kills off the add-on functionality... But, as n-gate usually writes, "Firefox tries to be more like Chrome"
[holli]: it's not always possible to do a complete rewrite without cutting off some pigtails
[Discipulus]: indeed! new firefox seems poorer: many tab crash, and you open this link in FF?
[Discipulus]: problem scrolling even main page..;=(
[LanX]: holli -> Good Intentions: Wikisyntax for the Monastery

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (12)
As of 2017-11-20 19:05 GMT
Find Nodes?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:

    Results (291 votes). Check out past polls.