113 void randomizeWeights();
140 bool testInference(
double *testInput,
double *testExpectedOutput);
180 bool randomizeWeights =
true
212 double *inputNeurons,
213 double *outputNeurons
283 double calculateAccuracy(
double *testInput,
double *testExpectedOutput,
int epoch);
298 double calculateLoss(
double *testInput,
double *testExpectedOutput,
int epoch);
Lightweight Feedforward Artificial Neural Network (ANN) library tailored for microcontrollers.
Definition diwa.h:89
double * inference(double *inputs)
Perform inference on the neural network.
Definition diwa.cpp:130
double calculateAccuracy(double *testInput, double *testExpectedOutput, int epoch)
Calculates the accuracy of the neural network on test data.
Definition diwa.cpp:466
DiwaError loadFromFile(std::ifstream &annFile)
Load neural network model from file in non-Arduino environment.
Definition diwa.cpp:378
diwa_activation getActivationFunction() const
Retrieves the current activation function used by the neural network.
Definition diwa.cpp:488
void train(double learningRate, double *inputNeurons, double *outputNeurons)
Train the neural network using backpropagation.
Definition diwa.cpp:182
int recommendedHiddenLayerCount(int numSamples, int alpha)
Calculates the recommended number of hidden layers based on the dataset size and complexity.
Definition diwa.cpp:499
double calculateLoss(double *testInput, double *testExpectedOutput, int epoch)
Calculates the loss of the neural network on test data.
Definition diwa.cpp:475
DiwaError initialize(int inputNeurons, int hiddenLayers, int hiddenNeurons, int outputNeurons, bool randomizeWeights=true)
Initializes the Diwa neural network with specified parameters.
Definition diwa.cpp:65
~Diwa()
Destructor for the Diwa class.
Definition diwa.cpp:52
Diwa()
Default constructor for the Diwa class.
Definition diwa.cpp:47
DiwaError saveToFile(std::ofstream &annFile)
Save neural network model to file in non-Arduino environment.
Definition diwa.cpp:432
void setActivationFunction(diwa_activation activation)
Sets the activation function for the neural network.
Definition diwa.cpp:484
int recommendedHiddenNeuronCount()
Calculates the recommended number of hidden neurons based on the input and output neurons.
Definition diwa.cpp:492
DiwaError
Enumeration representing various error codes that may occur during the operation of the Diwa library.
Definition diwa.h:61
@ MALLOC_FAILED
Definition diwa.h:68
@ MODEL_SAVE_ERROR
Definition diwa.h:65
@ STREAM_NOT_OPEN
Definition diwa.h:67
@ MODEL_READ_ERROR
Definition diwa.h:64
@ NO_ERROR
Definition diwa.h:62
@ INVALID_PARAM_VALUES
Definition diwa.h:63
@ INVALID_MAGIC_NUMBER
Definition diwa.h:66
Defines activation functions for use in the Diwa neural network.
double(* diwa_activation)(double)
Typedef for activation function pointer.
Definition diwa_activations.h:59