NeuraLegion / shainet

SHAInet - a pure Crystal machine learning library
MIT License
183 stars 19 forks source link

Optimize Neuron#activate method #66

Closed hugoabonizio closed 6 years ago

hugoabonizio commented 6 years ago

Avoid creating an intermediate array.

Running a benchmark shows this optimization converts into approximatelly 10% in performance gain on final Network#run method.

$ crystal run --release bench.cr 
original   1.86M (536.63ns) (± 4.24%)  1.13× slower
modified   2.11M (474.37ns) (± 4.32%)       fastest
ArtLinkov commented 6 years ago

Very nice! Thanks again @hugoabonizio :)