Skip to content

Commit 680700d

Browse files
committed
add DigitsExample + fix broken compile
1 parent 63651d6 commit 680700d

File tree

10 files changed

+2125
-20063
lines changed

10 files changed

+2125
-20063
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
cmake-build-debug
2-
.idea
2+
.idea
3+
src (copia)
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#include <EloquentTinyML.h>
2+
#include "digits_model.h"
3+
4+
#define NUMBER_OF_INPUTS 64
5+
#define NUMBER_OF_OUTPUTS 10
6+
// in future projects you may need to tweek this value: it's a trial and error process
7+
#define TENSOR_ARENA_SIZE 8*1024
8+
9+
Eloquent::TinyML::TfLite<NUMBER_OF_INPUTS, NUMBER_OF_OUTPUTS, TENSOR_ARENA_SIZE> ml;
10+
11+
12+
void setup() {
13+
Serial.begin(115200);
14+
ml.begin(digits_model);
15+
}
16+
17+
void loop() {
18+
// pick up a random x and predict its sine
19+
float x_test[64] = { 0. , 0. , 0.625 , 0.875 , 0.5 , 0.0625, 0. , 0. ,
20+
0. , 0.125 , 1. , 0.875 , 0.375 , 0.0625, 0. , 0. ,
21+
0. , 0. , 0.9375, 0.9375, 0.5 , 0.9375, 0. , 0. ,
22+
0. , 0. , 0.3125, 1. , 1. , 0.625 , 0. , 0. ,
23+
0. , 0. , 0.75 , 0.9375, 0.9375, 0.75 , 0. , 0. ,
24+
0. , 0.25 , 1. , 0.375 , 0.25 , 1. , 0.375 , 0. ,
25+
0. , 0.5 , 1. , 0.625 , 0.5 , 1. , 0.5 , 0. ,
26+
0. , 0.0625, 0.5 , 0.75 , 0.875 , 0.75 , 0.0625, 0. };
27+
float y_pred[10] = {0};
28+
int y_test = 8;
29+
30+
uint32_t start = micros();
31+
ml.predict(x_test, y_pred);
32+
uint32_t timeit = micros() - start;
33+
Serial.print("It took ");
34+
Serial.print(timeit);
35+
Serial.println(" micros to run inference");
36+
37+
Serial.print("Test output is: ");
38+
Serial.println(y_test);
39+
Serial.print("Predicted proba are: ");
40+
41+
for (int i = 0; i < 10; i++) {
42+
Serial.print(y_pred[i]);
43+
Serial.print(i == 9 ? '\n' : ',');
44+
}
45+
46+
uint8_t pred_class = 0;
47+
float max_proba = y_pred[0];
48+
49+
for (int i = 1; i < 10; i++) {
50+
if (y_pred[i] > max_proba) {
51+
pred_class = i;
52+
max_proba = y_pred[i];
53+
}
54+
}
55+
56+
Serial.print("Predicted output is: ");
57+
Serial.println(pred_class);
58+
59+
delay(1000);
60+
}

examples/DigitsExample/digits_model.h

Lines changed: 1807 additions & 0 deletions
Large diffs are not rendered by default.

examples/SineCosineExample/sine_cosine_model.py

Lines changed: 0 additions & 42 deletions
This file was deleted.

examples/SineExample/sine_model.h

Lines changed: 248 additions & 221 deletions
Large diffs are not rendered by default.

library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"type": "git",
77
"url": "https://github.com/eloquentarduino/EloquentTinyML"
88
},
9-
"version": "0.0.3",
9+
"version": "0.0.4",
1010
"authors": {
1111
"name": "Simone Salerno",
1212
"url": "https://github.com/eloquentarduino"

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=EloquentTinyML
2-
version=0.0.3
2+
version=0.0.4
33
author=Simone Salerno,[email protected]
44
maintainer=Simone Salerno,[email protected]
55
sentence=An eloquent interface to Tensorflow Lite for Microcontrollers

src/EloquentPersonDetector.h

Lines changed: 0 additions & 88 deletions
This file was deleted.

0 commit comments

Comments
 (0)