Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors various neural network classes to use the NumPower library. It introduces new implementations for neural network layers, networks, snapshots, and their corresponding test files. The changes also update documentation paths to reflect the new class structure organized into subdirectories.
Changes:
- Adds new neural network layer implementations (Dense, Activation, Binary, Continuous, Multiclass, Dropout, Noise, BatchNorm, PReLU, Swish, Placeholder1D) using NumPower
- Introduces Network and FeedForward classes with comprehensive test coverage
- Updates initializers to include explicit
locparameter for NumPower compatibility - Updates documentation paths to reflect new directory structure
Reviewed changes
Copilot reviewed 51 out of 51 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| src/NeuralNet/Networks/Network.php | New base Network class implementation using NumPower |
| src/NeuralNet/FeedForwards/FeedForward.php | New FeedForward network extending Network |
| src/NeuralNet/Layers//.php | New layer implementations (Dense, Activation, Binary, etc.) |
| src/NeuralNet/Snapshots/Snapshot.php | New snapshot class for network state management |
| tests/NeuralNet//.php | Comprehensive test coverage for new implementations |
| src/NeuralNet/Initializers//.php | Updated to include explicit loc parameter |
| docs/neural-network/hidden-layers/*.md | Documentation path updates |
| phpunit.xml | Memory limit increase for tests |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Hey @apphp I;m a little confused because I'm seeing some Neural Net layers in this PR and I thought those were handled in a separate PR. |
|
@andrewdalpino - this PR is based on previous PR #393 |
|
@apphp Gotcha, it's been targeted at the 3.0 branch even before #393 was merged so that made it confusing. In the future, let's target any sub branches of a "feature" branch at the feature branch instead of the "development" (3.0) branch. That way, the diff will be cleaner and easier to reason about. |
| */ | ||
| public function infer(Dataset $dataset) : NDArray | ||
| { | ||
| $input = NumPower::transpose(NumPower::array($dataset->samples()), [1, 0]); |
There was a problem hiding this comment.
This is working now? I remember you mentioned that we needed first "pack" (using array_values()) the dataset array first?
There was a problem hiding this comment.
Yes, you're right, but later I found a real source of the problem (it doesn't occurs in this PR, only in #397)
The REAL source of the problem was found in Parameter.php in this line of code:
$this->param = clone $this->param;
✘ Serialization preserves predict output
┐
├ Test was run in child process and ended unexpectedly
┴
So this line of code was replaced with
$this->param = NumPower::array($this->param->toArray());
with proper explanation.
and now it works as expected.
So, this line is OK:
$input = NumPower::transpose(NumPower::array($dataset->samples()), [1, 0]);
Let's see if it created time running issues, so we can think how to improve this code.
P.S. let's speak with @SkibidiProduction about clone operation for NDArray, because seems it doesn't work correctly.
There was a problem hiding this comment.
Aha thanks for the backstory that makes alot of sense now, glad we got that worked out! Nice job.
| * @author Andrew DalPino | ||
| * @author Samuel Akopyan <leumas.a@gmail.com> | ||
| */ | ||
| class Network |
There was a problem hiding this comment.
This class looks alot like FeedForward. Why both?
There was a problem hiding this comment.
Yes, this is how original Network and FeedForward classes where created.
FeedForward extends Network and they are exactly the same, so I created them in the same way for NumPower
There was a problem hiding this comment.
Hm, I don't doubt that's how they came, but that's definitely not how I intended them to be originally. Network should be an interface.
See the master branch https://github.com/RubixML/ML/blob/master/src/NeuralNet/Network.php
There was a problem hiding this comment.
Anyway, if you think it was done by mistake - I can convert it back into interface class.
But take in account we have few places in our code, where we create and use Network instance:
$this->network = new Network();

No description provided.