|Pathologically Eclectic Rubbish Lister|
Re: Hopfield Neural Network in perl6by liz (Monsignor)
|on Jun 30, 2018 at 07:45 UTC||Need Help??|
This looks pretty cool!
If you allow me to make some remarks: it looks like a very C-ish/Perl 5-ish piece of Perl 6 code.
And I think there is one error in it:
The $.weight is equivalent to self.weight. You can only use the accessor as a mutator if the attribute is marked is rw. So either you can change the assignment to $!weight = $y1 (directly accessing the attribute), or you can add is rw to the attribute declaration: has $.weight is rw. The choice is really whether you want the weight to be assignable from the outside or not and/or you want subclasses to be able to define their own "weight" method or not.
With regards to C-ism / Perl 5-isms: it feels to me that the following loop
could be simplified to:
This will iterate over all of the inputsynapses without needing to index. The +( ) is what transforms a Boolean True / False to 1 or 0.
Hope this helps