46# if defined(ARDUINO_ARCH_ESP32) || \
47 defined(ARDUINO_ARCH_ESP8266) || \
48 defined(ARDUINO_ARCH_RP2040)
53#elif defined(__GNUC__) || \
54 defined(__GNUG__) || \
55 defined(__clang__) || \
122 void randomizeWeights();
149 bool testInference(
double *testInput,
double *testExpectedOutput);
189 bool randomizeWeights =
true
221 double *inputNeurons,
222 double *outputNeurons
251 #elif defined(__GNUC__) || \
252 defined(__GNUG__) || \
253 defined(__clang__) || \
266 DiwaError loadFromFile(std::ifstream& annFile);
278 DiwaError saveToFile(std::ofstream& annFile);
295 double calculateAccuracy(
double *testInput,
double *testExpectedOutput,
int epoch);
310 double calculateLoss(
double *testInput,
double *testExpectedOutput,
int epoch);
Lightweight Feedforward Artificial Neural Network (ANN) library tailored for microcontrollers.
Definition diwa.h:98
double * inference(double *inputs)
Perform inference on the neural network.
Definition diwa.cpp:140
double calculateAccuracy(double *testInput, double *testExpectedOutput, int epoch)
Calculates the accuracy of the neural network on test data.
Definition diwa.cpp:478
diwa_activation getActivationFunction() const
Retrieves the current activation function used by the neural network.
Definition diwa.cpp:500
void train(double learningRate, double *inputNeurons, double *outputNeurons)
Train the neural network using backpropagation.
Definition diwa.cpp:192
int recommendedHiddenLayerCount(int numSamples, int alpha)
Calculates the recommended number of hidden layers based on the dataset size and complexity.
Definition diwa.cpp:511
double calculateLoss(double *testInput, double *testExpectedOutput, int epoch)
Calculates the loss of the neural network on test data.
Definition diwa.cpp:487
DiwaError initialize(int inputNeurons, int hiddenLayers, int hiddenNeurons, int outputNeurons, bool randomizeWeights=true)
Initializes the Diwa neural network with specified parameters.
Definition diwa.cpp:75
~Diwa()
Destructor for the Diwa class.
Definition diwa.cpp:62
Diwa()
Default constructor for the Diwa class.
Definition diwa.cpp:57
void setActivationFunction(diwa_activation activation)
Sets the activation function for the neural network.
Definition diwa.cpp:496
int recommendedHiddenNeuronCount()
Calculates the recommended number of hidden neurons based on the input and output neurons.
Definition diwa.cpp:504
DiwaError
Enumeration representing various error codes that may occur during the operation of the Diwa library.
Definition diwa.h:70
@ MALLOC_FAILED
Definition diwa.h:77
@ MODEL_SAVE_ERROR
Definition diwa.h:74
@ STREAM_NOT_OPEN
Definition diwa.h:76
@ MODEL_READ_ERROR
Definition diwa.h:73
@ NO_ERROR
Definition diwa.h:71
@ INVALID_PARAM_VALUES
Definition diwa.h:72
@ INVALID_MAGIC_NUMBER
Definition diwa.h:75
Defines activation functions for use in the Diwa neural network.
double(* diwa_activation)(double)
Typedef for activation function pointer.
Definition diwa_activations.h:59