forked from fedetft/miosix-kernel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNeuralNetwork.h
51 lines (41 loc) · 1.39 KB
/
NeuralNetwork.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
* File: NeuralNetwork_.h
* Author: nicolo
*
* Created on January 21, 2020, 7:14 PM
*/
#ifndef NEURALNETWORK_H
#define NEURALNETWORK_H
#include "SyncQueue.h"
#include "ActiveObject.h"
#include "NN/Inc/network.h"
#include "NN/Inc/network_data.h"
#include "UsefulTypedefs.h"
class NeuralNetwork : public ActiveObject {
public:
NeuralNetwork(SyncQueue<float> &queue, const OdrMode& odr);
~NeuralNetwork();
private:
SyncQueue<float>& queue;
unsigned int acquiredValues = 0;
ai_float incrementalMean = 0;
OdrMode odr;
ai_float in_data[AI_NETWORK_IN_1_SIZE] = {0, 0, 0};
ai_handle network = AI_HANDLE_NULL;
ai_u8 activations[AI_NETWORK_DATA_ACTIVATIONS_SIZE];
ai_buffer nn_input[AI_NETWORK_IN_NUM] = AI_NETWORK_IN;
ai_buffer nn_output[AI_NETWORK_OUT_NUM] = AI_NETWORK_OUT;
ai_float nn_outdata[AI_NETWORK_OUT_1_SIZE];
// hard-coded normalization parameters obtained at training time
const float normMin = 978.52708333;
const float normMax = 1040.8893617;
void initNN();
void run();
int runNN(ai_handle network, void* input);
void enqueue (ai_float* input, ai_float newValue);
ai_float* normalizeInput(ai_float* input);
float denormalizeOutput(float output);
NeuralNetwork(const NeuralNetwork& orig) = delete;
NeuralNetwork& operator=(const NeuralNetwork& orig) = delete;
};
#endif /* NEURALNETWORK__H */