32#include <SoftwareSerial.h>
36#define N2CMU_RESET_TIMEOUT 4558
49 SoftwareSerial *n2serial;
60 bool getResultStatus();
67 bool sendCommand(uint8_t command);
91 void writeF32(
float data);
97 void writeU16(uint16_t data);
104 void writeData(
const uint8_t *data, uint8_t length);
119 ): n2serial(new SoftwareSerial(rx, tx)) { }
212 bool infer(
float* input,
float* output);
533 void loadFromFile(
const char *modelFilename);
536 void saveToFile(
const char* modelFilename);
Class representing the N2CMU device.
Definition: n2cmu.h:47
void setHiddenCount(uint8_t hiddenCount)
Set the number of hidden neurons.
Definition: n2cmu.cpp:178
bool infer(float *input, float *output)
Make inference with the neural network using provided input data.
Definition: n2cmu.cpp:146
void createNetwork(uint8_t inputCount, uint8_t hiddenCount, uint8_t outputCount)
Create a neural network with specified input, hidden, and output neuron counts.
Definition: n2cmu.cpp:104
bool train(float *data, float *output, uint16_t len, float learningRate)
Train the neural network with provided data and output.
Definition: n2cmu.cpp:119
uint8_t getOutputCount()
Get the number of output neurons.
Definition: n2cmu.cpp:201
void getOutputBias(float *outputBias)
Get output neuron biases.
Definition: n2cmu.cpp:320
bool cpuReset()
Reset the CPU of the N2CMU device.
Definition: n2cmu.cpp:97
void getOutputNeuron(float *outputNeuron)
Get output neuron values.
Definition: n2cmu.cpp:244
bool setHiddenBias(float *hiddenBias)
Set hidden neuron biases.
Definition: n2cmu.cpp:292
void getHiddenNeuron(float *hiddenNeuron)
Get hidden neuron values.
Definition: n2cmu.cpp:226
N2Coprocessor(uint8_t rx=N2CMU_RX_PIN, uint8_t tx=N2CMU_TX_PIN)
Constructor for N2Coprocessor class.
Definition: n2cmu.h:116
bool setOutputWeights(float *outputWeights)
Set output neuron weights.
Definition: n2cmu.cpp:272
bool begin()
Initialize the N2CMU device.
Definition: n2cmu.cpp:86
void getOutputWeights(float *outputWeights)
Get output neuron weights.
Definition: n2cmu.cpp:283
bool setOutputGradient(float *outputGrad)
Set output neuron gradients.
Definition: n2cmu.cpp:346
void setInputCount(uint8_t inputCount)
Set the number of input neurons.
Definition: n2cmu.cpp:164
bool setHiddenNeuron(float *hiddenNeuron)
Set hidden neuron values.
Definition: n2cmu.cpp:216
void getHiddenGradient(float *hiddenGrad)
Get hidden neuron gradients.
Definition: n2cmu.cpp:338
bool setHiddenGradient(float *hiddenGrad)
Set hidden neuron gradients.
Definition: n2cmu.cpp:328
void setOutputCount(uint8_t outputCount)
Set the number of output neurons.
Definition: n2cmu.cpp:192
bool handshake()
Perform handshake with the N2CMU device.
Definition: n2cmu.cpp:93
void setEpochCount(uint16_t epoch)
Set the epoch count for training.
Definition: n2cmu.cpp:206
void resetNetwork()
Reset the neural network parameters.
Definition: n2cmu.cpp:160
void getOutputGradient(float *outputGrad)
Get output neuron gradients.
Definition: n2cmu.cpp:356
uint16_t getEpochCount()
Get the epoch count for training.
Definition: n2cmu.cpp:211
void getHiddenBias(float *hiddenBias)
Get hidden neuron biases.
Definition: n2cmu.cpp:302
uint8_t getHiddenCount()
Get the number of hidden neurons.
Definition: n2cmu.cpp:187
bool setOutputNeuron(float *outputNeuron)
Set output neuron values.
Definition: n2cmu.cpp:234
uint8_t getInputCount()
Get the number of input neurons.
Definition: n2cmu.cpp:173
void getHiddenWeights(float *hiddenWeights)
Get hidden neuron weights.
Definition: n2cmu.cpp:263
bool setOutputBias(float *outputBias)
Set output neuron biases.
Definition: n2cmu.cpp:310
bool setHiddenWeights(float *hiddenWeights)
Set hidden neuron weights.
Definition: n2cmu.cpp:252
#define N2CMU_TX_PIN
Pin number for transmitting data to N2CMU.
Definition: n2cmu.h:35
#define N2CMU_RX_PIN
Pin number for receiving data from N2CMU.
Definition: n2cmu.h:34