FlexNN 1
Fully connected neural network built from scratch with flexible n-layer design and multiple activations.
Loading...
Searching...
No Matches
Utility.cpp File Reference

Implements FlexNN utilities with deterministic seeding. More...

#include "Utility.h"
#include <algorithm>
#include <atomic>
#include <cstdint>
#include <fstream>
#include <numeric>
#include <random>
#include <sstream>
#include <string>
#include <vector>
#include <Eigen/Dense>
Include dependency graph for Utility.cpp:

Namespaces

namespace  FlexNN
 Namespace for the FlexNN neural network library.
 

Functions

void FlexNN::setRandomSeed (uint32_t seed)
 Set the global RNG seed for splitXY (deterministic splits).
 
uint32_t FlexNN::getRandomSeed () noexcept
 Get the current global RNG seed.
 
Eigen::MatrixXd FlexNN::oneHotEncode (const Eigen::VectorXd &Y, int num_classes)
 One-hot encodes a vector of class labels.
 
void FlexNN::readCSV_XY (const std::string &filename, Eigen::MatrixXd &X, Eigen::VectorXd &Y)
 Reads a CSV where first column is label, rest are features.
 
std::vector< std::pair< Eigen::MatrixXd, Eigen::VectorXd > > FlexNN::splitXY (const Eigen::MatrixXd &X, const Eigen::VectorXd &Y, const std::vector< double > &proportions)
 Splits dataset into multiple sets by proportions (uses global seed).
 
std::vector< std::pair< Eigen::MatrixXd, Eigen::VectorXd > > FlexNN::splitXY (const Eigen::MatrixXd &X, const Eigen::VectorXd &Y, const std::vector< double > &proportions, uint32_t seed)
 Splits dataset with explicit seed (deterministic, no global state).
 

Detailed Description

Implements FlexNN utilities with deterministic seeding.

Why this file: splitXY was nondeterministic (random_device per call) which broke test hermeticity. Now setRandomSeed + thread_local mt19937 makes it deterministic when needed, while keeping the old signature for backward compat (see LLD_FLEXNN ยง8).