File tree Expand file tree Collapse file tree 2 files changed +69
-4
lines changed Expand file tree Collapse file tree 2 files changed +69
-4
lines changed Original file line number Diff line number Diff line change
1
+ # EloquentTinyML
2
+
3
+ This Arduino library is here to simplify the deployment of Tensorflow Lite
4
+ for Microcontrollers models to Arduino boards using the Arduino IDE.
5
+
6
+ Including all the required files for you, the library exposes an eloquent
7
+ interface to load a model and run inferences.
8
+
9
+ ## Install
10
+
11
+ Clone this repo in you Arduino libraries folder.
12
+
13
+ ``` bash
14
+ git clone https://github.com/eloquentarduino/EloquentTinyML.git
15
+ ```
16
+
17
+
18
+ ## Use
19
+
20
+ ``` cpp
21
+ #include < EloquentTinyML.h>
22
+ #include " sine_model.h"
23
+
24
+ #define NUMBER_OF_INPUTS 1
25
+ #define NUMBER_OF_OUTPUTS 1
26
+ #define TENSOR_ARENA_SIZE 2* 1024
27
+
28
+ Eloquent::TinyML::TinyML<
29
+ NUMBER_OF_INPUTS,
30
+ NUMBER_OF_OUTPUTS,
31
+ TENSOR_ARENA_SIZE> ml (sine_model_quantized_tflite);
32
+
33
+
34
+ void setup() {
35
+ Serial.begin(115200);
36
+ }
37
+
38
+ void loop() {
39
+ float x = 3.14 * random(100) / 100;
40
+ float y = sin(x);
41
+ float input[ 1] = { x };
42
+ float predicted = ml.predict(input);
43
+
44
+ Serial.print("sin(");
45
+ Serial.print(x);
46
+ Serial.print(") = ");
47
+ Serial.print(y);
48
+ Serial.print("\t predicted: ");
49
+ Serial.println(predicted);
50
+ delay(1000);
51
+ }
52
+ ```
Original file line number Diff line number Diff line change 1
1
#include < EloquentTinyML.h>
2
2
#include " sine_model.h"
3
3
4
+ #define NUMBER_OF_INPUTS 1
5
+ #define NUMBER_OF_OUTPUTS 1
6
+ #define TENSOR_ARENA_SIZE 2 *1024
4
7
5
- Eloquent::TinyML::TinyML<1 , 1 , 2048 > ml (sine_model_quantized_tflite);
8
+ Eloquent::TinyML::TinyML<
9
+ NUMBER_OF_INPUTS,
10
+ NUMBER_OF_OUTPUTS,
11
+ TENSOR_ARENA_SIZE> ml (sine_model_quantized_tflite);
6
12
7
13
8
14
void setup () {
9
15
Serial.begin (115200 );
10
16
}
11
17
12
18
void loop () {
13
- float input[1 ] = {random (10 ) > 5 ? 3.14 /2 : 0 };
14
- float output = ml.predict (input);
19
+ float x = 3.14 * random (100 ) / 100 ;
20
+ float y = sin (x);
21
+ float input[1 ] = { x };
22
+ float predicted = ml.predict (input);
15
23
16
- Serial.println (output);
24
+ Serial.print (" sin(" );
25
+ Serial.print (x);
26
+ Serial.print (" ) = " );
27
+ Serial.print (y);
28
+ Serial.print (" \t predicted: " );
29
+ Serial.println (predicted);
17
30
delay (1000 );
18
31
}
You can’t perform that action at this time.
0 commit comments