-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b4aa86c
commit 708186e
Showing
2 changed files
with
69 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# EloquentTinyML | ||
|
||
This Arduino library is here to simplify the deployment of Tensorflow Lite | ||
for Microcontrollers models to Arduino boards using the Arduino IDE. | ||
|
||
Including all the required files for you, the library exposes an eloquent | ||
interface to load a model and run inferences. | ||
|
||
## Install | ||
|
||
Clone this repo in you Arduino libraries folder. | ||
|
||
```bash | ||
git clone https://github.com/eloquentarduino/EloquentTinyML.git | ||
``` | ||
|
||
|
||
## Use | ||
|
||
```cpp | ||
#include <EloquentTinyML.h> | ||
#include "sine_model.h" | ||
|
||
#define NUMBER_OF_INPUTS 1 | ||
#define NUMBER_OF_OUTPUTS 1 | ||
#define TENSOR_ARENA_SIZE 2*1024 | ||
|
||
Eloquent::TinyML::TinyML< | ||
NUMBER_OF_INPUTS, | ||
NUMBER_OF_OUTPUTS, | ||
TENSOR_ARENA_SIZE> ml(sine_model_quantized_tflite); | ||
|
||
|
||
void setup() { | ||
Serial.begin(115200); | ||
} | ||
|
||
void loop() { | ||
float x = 3.14 * random(100) / 100; | ||
float y = sin(x); | ||
float input[1] = { x }; | ||
float predicted = ml.predict(input); | ||
|
||
Serial.print("sin("); | ||
Serial.print(x); | ||
Serial.print(") = "); | ||
Serial.print(y); | ||
Serial.print("\t predicted: "); | ||
Serial.println(predicted); | ||
delay(1000); | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,31 @@ | ||
#include <EloquentTinyML.h> | ||
#include "sine_model.h" | ||
|
||
#define NUMBER_OF_INPUTS 1 | ||
#define NUMBER_OF_OUTPUTS 1 | ||
#define TENSOR_ARENA_SIZE 2*1024 | ||
|
||
Eloquent::TinyML::TinyML<1, 1, 2048> ml(sine_model_quantized_tflite); | ||
Eloquent::TinyML::TinyML< | ||
NUMBER_OF_INPUTS, | ||
NUMBER_OF_OUTPUTS, | ||
TENSOR_ARENA_SIZE> ml(sine_model_quantized_tflite); | ||
|
||
|
||
void setup() { | ||
Serial.begin(115200); | ||
} | ||
|
||
void loop() { | ||
float input[1] = {random(10) > 5 ? 3.14/2 : 0}; | ||
float output = ml.predict(input); | ||
float x = 3.14 * random(100) / 100; | ||
float y = sin(x); | ||
float input[1] = { x }; | ||
float predicted = ml.predict(input); | ||
|
||
Serial.println(output); | ||
Serial.print("sin("); | ||
Serial.print(x); | ||
Serial.print(") = "); | ||
Serial.print(y); | ||
Serial.print("\t predicted: "); | ||
Serial.println(predicted); | ||
delay(1000); | ||
} |