117 void randomizeWeights();
144 bool testInference(
double *testInput,
double *testExpectedOutput);
184 bool randomizeWeights =
true
216 double *inputNeurons,
217 double *outputNeurons
302 double calculateLoss(
double *testInput,
double *testExpectedOutput,
int epoch);
Lightweight Feedforward Artificial Neural Network (ANN) library tailored for microcontrollers.
Definition diwa.h:93
double * inference(double *inputs)
Perform inference on the neural network.
double calculateAccuracy(double *testInput, double *testExpectedOutput, int epoch)
Calculates the accuracy of the neural network on test data.
DiwaError loadFromFile(std::ifstream &annFile)
Load neural network model from file in non-Arduino environment.
diwa_activation getActivationFunction() const
Retrieves the current activation function used by the neural network.
void train(double learningRate, double *inputNeurons, double *outputNeurons)
Train the neural network using backpropagation.
int recommendedHiddenLayerCount(int numSamples, int alpha)
Calculates the recommended number of hidden layers based on the dataset size and complexity.
double calculateLoss(double *testInput, double *testExpectedOutput, int epoch)
Calculates the loss of the neural network on test data.
DiwaError initialize(int inputNeurons, int hiddenLayers, int hiddenNeurons, int outputNeurons, bool randomizeWeights=true)
Initializes the Diwa neural network with specified parameters.
~Diwa()
Destructor for the Diwa class.
Diwa()
Default constructor for the Diwa class.
DiwaError saveToFile(std::ofstream &annFile)
Save neural network model to file in non-Arduino environment.
void setActivationFunction(diwa_activation activation)
Sets the activation function for the neural network.
int recommendedHiddenNeuronCount()
Calculates the recommended number of hidden neurons based on the input and output neurons.
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:58