Skip to content

Conversation

@dlidstrom
Copy link
Owner

This commit refactors the neural network prediction process by replacing the overloaded Predict method with two distinct functions. The first function now returns the output vector, while the second fills the provided vectors for hidden and output layers directly. Additionally, object initialization in the Create methods of the Trainer class has been optimized using move semantics, and unnecessary copies have been eliminated for improved performance and memory efficiency. These changes enhance code clarity and reduce potential overheads during the prediction and training processes.

… and optimize memory handling

This commit refactors the neural network prediction process by replacing the overloaded Predict method with two distinct functions. The first function now returns the output vector, while the second fills the provided vectors for hidden and output layers directly. Additionally, object initialization in the Create methods of the Trainer class has been optimized using move semantics, and unnecessary copies have been eliminated for improved performance and memory efficiency. These changes enhance code clarity and reduce potential overheads during the prediction and training processes.
Replaced std::function<double()> with a typedef RandFcn in neural.cpp and neural.h for improved code readability and maintainability. This change simplifies the function signature and makes it easier to update or replace the random function type in the future. No functional changes were made.
@dlidstrom dlidstrom merged commit b4935a1 into main Nov 10, 2025
10 checks passed
@dlidstrom dlidstrom deleted the cpp_fixes branch November 10, 2025 08:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants