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
277 #elif defined(__GNUC__) || \
278 defined(__GNUG__) || \
279 defined(__clang__) || \
321 double calculateAccuracy(
double *testInput,
double *testExpectedOutput,
int epoch);
336 double calculateLoss(
double *testInput,
double *testExpectedOutput,
int epoch);
Lightweight Feedforward Artificial Neural Network (ANN) library tailored for microcontrollers.
Definition diwa.h:98
int getHiddenNeurons() const
Get the number of neurons in the hidden layer.
Definition diwa.cpp:523
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
DiwaError loadFromFile(T annFile)
Load neural network model from file in Arduino environment.
int getNeuronCount() const
Get the total number of neurons in the neural network.
Definition diwa.cpp:539
void getOutputs(double *outputs)
Retrieve the outputs of the neural network.
Definition diwa.cpp:547
diwa_activation getActivationFunction() const
Retrieves the current activation function used by the neural network.
Definition diwa.cpp:495
int getHiddenLayers() const
Get the number of hidden layers in the neural network.
Definition diwa.cpp:527
DiwaError saveToFile(T annFile)
Save neural network model to file in Arduino environment.
void train(double learningRate, double *inputNeurons, double *outputNeurons)
Train the neural network using backpropagation.
Definition diwa.cpp:192
int getOutputNeurons() const
Get the number of output neurons in the neural network.
Definition diwa.cpp:531
int recommendedHiddenLayerCount(int numSamples, int alpha)
Calculates the recommended number of hidden layers based on the dataset size and complexity.
Definition diwa.cpp:506
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:491
void getWeights(double *weights)
Retrieve the weights of the neural network.
Definition diwa.cpp:543
int getWeightCount() const
Get the total number of weights in the neural network.
Definition diwa.cpp:535
int getInputNeurons() const
Get the number of input neurons in the neural network.
Definition diwa.cpp:519
int recommendedHiddenNeuronCount()
Calculates the recommended number of hidden neurons based on the input and output neurons.
Definition diwa.cpp:499
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