Add activation functions and optimizer support#11
Merged
Conversation
This commit adds comprehensive support for multiple activation functions and modern optimizers to the neural network library. New Features: - Activation functions: ReLU, Leaky ReLU, Tanh, Softmax, ELU, SELU, Linear (in addition to existing Sigmoid) - Optimizers: SGD, Momentum, Adam with configurable hyperparameters - Layer-level activation configuration - Network-level optimizer configuration - Unified activation interface with forward and gradient functions Implementation Details: - Created activation.h with 8 activation functions and their gradients - Created optimizer.h with 3 optimizer implementations - Updated Layer class to support configurable activation types - Updated Network class to use optimizer pattern - Updated backpropagation to use correct activation gradients - Added comprehensive test suite for all new features Tests: - test_activations_optimizers.cpp validates all activation functions - Tests verify optimizer behavior (SGD, Momentum, Adam) - Integration tests ensure network works with new features - All tests passing Documentation: - Updated README with comprehensive feature list - Added "What's Available" and "What's Missing" sections - Updated usage examples to show new activation and optimizer APIs - Added examples for all activation functions and optimizers Bug Fixes: - Added missing <memory> and <omp.h> includes - Removed duplicate Sigmoid/SigGrad functions from network.h
oulrich1
pushed a commit
that referenced
this pull request
Nov 17, 2025
- Fix SigGrad template function compilation error by using Diff(T(1), mat) instead of Diff<T>(1, mat) to properly cast the literal - Fix printf format specifiers in matrix.cpp (%0.2l -> %ld, %0.2d -> %d, %0.2u -> %u) - Remove invalid precision specifiers from integer format strings These changes resolve the compilation errors that were preventing the PR build from succeeding.
oulrich1
added a commit
that referenced
this pull request
Nov 17, 2025
- Fix SigGrad template function compilation error by using Diff(T(1), mat) instead of Diff<T>(1, mat) to properly cast the literal - Fix printf format specifiers in matrix.cpp (%0.2l -> %ld, %0.2d -> %d, %0.2u -> %u) - Remove invalid precision specifiers from integer format strings These changes resolve the compilation errors that were preventing the PR build from succeeding. Co-authored-by: Claude <noreply@anthropic.com>
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.
This commit adds comprehensive support for multiple activation functions and modern optimizers to the neural network library.
New Features:
Implementation Details:
Tests:
Documentation:
Bug Fixes: