|
NoJobEngine 2.0.7
|
CPU-based feed-forward neural network with native C++ training. More...
#include <NeuralNetwork.h>
Public Member Functions | |
| NeuralNetwork (uint32_t seed=42) | |
| void | AddDense (size_t inputs, size_t outputs, Activation activation) |
| Appends a dense layer to the network. | |
| std::vector< float > | Predict (const std::vector< float > &input) const |
| Evaluates the network without changing its parameters. | |
| TrainingHistory | Train (const std::vector< std::vector< float > > &inputs, const std::vector< std::vector< float > > &targets, const TrainingOptions &options={}, const std::function< bool(size_t, float)> &onEpoch={}) |
| Trains on paired input and target samples. | |
| float | MeanSquaredError (const std::vector< std::vector< float > > &inputs, const std::vector< std::vector< float > > &targets) const |
| void | Save (const std::string &path) const |
| Serializes the network to a model asset. | |
| const std::vector< DenseLayer > & | Layers () const |
| std::vector< DenseLayer > & | Layers () |
Static Public Member Functions | |
| static NeuralNetwork | Load (const std::string &path) |
| Loads a serialized network. | |
CPU-based feed-forward neural network with native C++ training.
Definition at line 32 of file NeuralNetwork.h.
|
inlineexplicit |
Definition at line 34 of file NeuralNetwork.h.
Referenced by Load().
| void NoJob::Neural::NeuralNetwork::AddDense | ( | size_t | inputs, |
| size_t | outputs, | ||
| Activation | activation ) |
Appends a dense layer to the network.
| inputs | Number of expected input features. |
| outputs | Number of output neurons. |
| activation | Activation function used by this layer. |
Definition at line 11 of file NeuralNetwork.cpp.
Referenced by Load(), main(), and NoJob::NeuralAgent::TrainPreset().
|
inline |
Definition at line 60 of file NeuralNetwork.h.
|
inline |
Definition at line 59 of file NeuralNetwork.h.
Referenced by NoJob::NeuralAgent::Activations(), and NoJob::NeuralAgent::TrainPreset().
|
static |
Loads a serialized network.
| path | Source model path. |
Definition at line 34 of file NeuralNetwork.cpp.
References AddDense(), and NeuralNetwork().
Referenced by NoJob::BTAssetAgent::CreateTree(), main(), NoJob::GenericNeuralAgent::OnCreate(), NoJob::NeuralTrainingAgent::OnCreate(), and NoJob::NeuralAgent::TrainPreset().
| float NoJob::Neural::NeuralNetwork::MeanSquaredError | ( | const std::vector< std::vector< float > > & | inputs, |
| const std::vector< std::vector< float > > & | targets ) const |
Definition at line 13 of file NeuralNetwork.cpp.
References Predict().
| std::vector< float > NoJob::Neural::NeuralNetwork::Predict | ( | const std::vector< float > & | input | ) | const |
Evaluates the network without changing its parameters.
| input | Input feature vector, matching the first layer width. |
Definition at line 12 of file NeuralNetwork.cpp.
Referenced by main(), and MeanSquaredError().
| void NoJob::Neural::NeuralNetwork::Save | ( | const std::string & | path | ) | const |
Serializes the network to a model asset.
| path | Destination file path. |
Definition at line 33 of file NeuralNetwork.cpp.
Referenced by main(), and NoJob::NeuralAgent::TrainPreset().
| TrainingHistory NoJob::Neural::NeuralNetwork::Train | ( | const std::vector< std::vector< float > > & | inputs, |
| const std::vector< std::vector< float > > & | targets, | ||
| const TrainingOptions & | options = {}, | ||
| const std::function< bool(size_t, float)> & | onEpoch = {} ) |
Trains on paired input and target samples.
| inputs | Training observations. |
| targets | Expected outputs for each observation. |
| options | Training hyperparameters. |
| onEpoch | Optional progress callback; its return value can control continuation. |
Definition at line 14 of file NeuralNetwork.cpp.
References NoJob::Neural::TrainingOptions::adam, NoJob::Neural::TrainingOptions::batchSize, NoJob::Neural::DerivativeFromOutput(), NoJob::Neural::TrainingHistory::epochLoss, NoJob::Neural::TrainingOptions::epochs, NoJob::Neural::TrainingOptions::learningRate, MeanSquaredError(), and NoJob::Neural::TrainingOptions::seed.
Referenced by main(), and NoJob::NeuralAgent::TrainPreset().