Open
Conversation
Author
There was a problem hiding this comment.
Pull request overview
This PR reintroduces a neural-network “Network” interface and updates instantiation sites/tests to construct FeedForward networks instead of the removed Network concrete class, alongside reorganizing the NDArray-based network code under NeuralNet\Networks\Base\....
Changes:
- Replace
new Network(...)withnew FeedForward(...)across learners and tests. - Introduce
src/NeuralNet/Networks/Base/Contracts/Network.phpand refactor the NDArray-basedFeedForwardnetwork to implement it; remove the oldsrc/NeuralNet/Networks/Network.php. - Update snapshot/network tests and adjust one Swish layer expected value; update changelog entries.
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/NeuralNet/Snapshots/SnapshotTest.php | Switch snapshot test to NDArray “Base” FeedForward + new Network contract. |
| tests/NeuralNet/SnapshotTest.php | Switch legacy snapshot test to instantiate FeedForward instead of Network. |
| tests/NeuralNet/Networks/NetworkTest.php | Update NDArray network test imports and construction to use Base FeedForward. |
| tests/NeuralNet/NetworkTest.php | Switch legacy network test construction to FeedForward. |
| tests/NeuralNet/Layers/Swish/SwishTest.php | Update expected numeric output to match current computation. |
| tests/NeuralNet/FeedForwards/FeedForwardTest.php | Point feedforward tests at Base FeedForward and new contracts. |
| src/Regressors/MLPRegressor.php | Use FeedForward for the underlying network construction. |
| src/Regressors/Adaline.php | Use FeedForward for the underlying network construction. |
| src/NeuralNet/Snapshots/Snapshot.php | Update snapshot to accept Base Network contract. |
| src/NeuralNet/Networks/Network.php | Remove the old NDArray Network concrete class. |
| src/NeuralNet/Networks/Base/FeedForward/FeedForward.php | Move/rename Base FeedForward, implement Base Network contract, add sample-normalization branch. |
| src/NeuralNet/Networks/Base/Contracts/Network.php | Add Base Network interface (input/hidden/output/layers). |
| src/NeuralNet/Network.php | Convert legacy Network to an interface (currently only layers()). |
| src/NeuralNet/FeedForward.php | Update legacy FeedForward to implement the legacy Network interface. |
| src/Classifiers/SoftmaxClassifier.php | Construct FeedForward network instead of Network. |
| src/Classifiers/MultilayerPerceptron.php | Construct FeedForward network instead of Network. |
| src/Classifiers/LogisticRegression.php | Construct FeedForward network instead of Network. |
| CHANGELOG.md | Note NDArray conversion + “converted back Network interface” entry. |
Comments suppressed due to low confidence (2)
src/NeuralNet/Networks/Base/FeedForward/FeedForward.php:214
- The empty-dataset fast path (
if ($dataset->empty()) return ...) and the 1D-shape reshape are currently guarded by$this->normalizeSamples, but that flag is never enabled. If these safeguards are needed to avoid NumPower edge cases, they should be applied unconditionally (or the flag needs to be configurable) so inference on empty/non-packed samples is actually protected.
src/NeuralNet/Networks/Base/FeedForward/FeedForward.php:101 $this->normalizeSamplesis initialized tofalseand the property isprivate, but there is no constructor parameter or method to ever set it totrue(confirmed by repo-wide search). This makes the normalization/reshape logic ininfer()and thenormalizeSamples()helper effectively dead code. Consider either removing the flag and always normalizing (if required for NumPower), or exposing a supported way to enable it (constructor arg or public setter).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

No description provided.