Skip to content

Commit 76d7959

Browse files
committed
refactor(core): introduce RandFcn typedef for random function
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.
1 parent b80c977 commit 76d7959

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

Cpp/neural.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ Trainer Trainer::Create(Neural::Network network) {
7272
}
7373

7474
Trainer Trainer::Create(size_t inputCount, size_t hiddenCount,
75-
size_t outputCount, std::function<double()> rand) {
75+
size_t outputCount, RandFcn rand) {
7676
Vector hidden(hiddenCount);
7777
Vector output(outputCount);
7878
Vector gradHidden(hiddenCount);

Cpp/neural.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2626
namespace Neural {
2727
typedef std::vector<double> Vector;
2828
typedef std::vector<Vector> Matrix;
29+
typedef std::function<double()> RandFcn;
2930
struct Network {
3031
size_t inputCount;
3132
size_t hiddenCount;
@@ -46,7 +47,7 @@ struct Trainer {
4647
Vector gradOutput;
4748
static Trainer Create(Neural::Network network);
4849
static Trainer Create(size_t inputCount, size_t hiddenCount,
49-
size_t outputCount, std::function<double()> rand);
50+
size_t outputCount, RandFcn rand);
5051
void Train(const Vector &input, const Vector &output, double lr);
5152
};
5253
} // namespace Neural

0 commit comments

Comments
 (0)