in reply to Basic Neural Network in PDL

++Very nice. I had been thinking about brushing up on my neural net skills (they're 20years rusty), and I've bookmarked this this will be a good starting point for using PDL to do so.

My one minor nitpick: the sigmoid function you chose, the "logistic function", has a derivative that's `f(x) * (1-f(x))`, not `x * (1-x)`, so you should replace your `nonlin()` sub with

... It still trains with your slope, but with my slope, it gets there faster, so 10k training loops gives better results:sub nonlin { my ( $x, $deriv ) = @_; my $f = 1 / ( 1 + exp( -$x ) ); return $f * ( 1 - $f ) if defined $deriv; return $f; }

Output After Training: [ [ 0.0007225057] [0.00048051061] [ 0.999593] [ 0.999388] ]

In Section
Cool Uses for Perl