417 convert classifiers to numpower - #418
Conversation
andrewdalpino
left a comment
There was a problem hiding this comment.
Looks good @samuel-akopyan nice work as usual. I a have a couple questions and things that stood out to me.
| } | ||
|
|
||
| return NumPower::array($result); | ||
| $max = NumPower::reshape(NumPower::array($maxima), [1, $columns]); |
There was a problem hiding this comment.
Did we forget to implement this during the Activation Functions sprint? Was it intentional to leave out due to the NumPower max() API limitation?
There was a problem hiding this comment.
Yes, it was Intentional. Softmax was rewritten to NumPower with stable max-subtraction, because NumPower::max() has no axis (stubs: scalar-only). Once NumPower adds max(..., axis:), we can drop the PHP loop.
| $expected = []; | ||
|
|
||
| foreach ($labels as $label) { | ||
| $dist = []; |
There was a problem hiding this comment.
What was the purpose of this change?
There was a problem hiding this comment.
Dense outputs [classes, batch], but the old one-hot was [batch, classes]. That shape mismatch broke SoftmaxClassifier training. This change should build the targets in the same layout as the network output.
No description provided.