Update Hello World example.
PiperOrigin-RevId: 310263402 Change-Id: I921176f6a8dc4c76bd45e6a508548d3b1936f89d
|
@ -71,7 +71,7 @@ important to change the array declaration to `const` for better memory
|
||||||
efficiency on embedded platforms.
|
efficiency on embedded platforms.
|
||||||
|
|
||||||
For an example of how to include and use a model in your program, see
|
For an example of how to include and use a model in your program, see
|
||||||
[`sine_model_data.cc`](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/lite/micro/examples/hello_world/sine_model_data.cc)
|
[`model.cc`](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/lite/micro/examples/hello_world/model.cc)
|
||||||
in the *Hello World* example.
|
in the *Hello World* example.
|
||||||
|
|
||||||
## Model architecture and training
|
## Model architecture and training
|
||||||
|
|
|
@ -86,12 +86,10 @@ World README.md</a>
|
||||||
|
|
||||||
The following section walks through the *Hello World* example's
|
The following section walks through the *Hello World* example's
|
||||||
[`hello_world_test.cc`](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/lite/micro/examples/hello_world/hello_world_test.cc),
|
[`hello_world_test.cc`](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/lite/micro/examples/hello_world/hello_world_test.cc),
|
||||||
which demonstrates how to run inference using TensorFlow Lite for
|
unit test which demonstrates how to run inference using TensorFlow Lite for
|
||||||
Microcontrollers.
|
Microcontrollers. It loads the model and runs inference several times.
|
||||||
|
|
||||||
The test loads the model and then uses it to run inference several times.
|
### 1. Include the library headers
|
||||||
|
|
||||||
### Include the library headers
|
|
||||||
|
|
||||||
To use the TensorFlow Lite for Microcontrollers library, we must include the
|
To use the TensorFlow Lite for Microcontrollers library, we must include the
|
||||||
following header files:
|
following header files:
|
||||||
|
@ -116,22 +114,20 @@ following header files:
|
||||||
- [`version.h`](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/lite/version.h)
|
- [`version.h`](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/lite/version.h)
|
||||||
provides versioning information for the TensorFlow Lite schema.
|
provides versioning information for the TensorFlow Lite schema.
|
||||||
|
|
||||||
### Include the model
|
### 2. Include the model header
|
||||||
|
|
||||||
The TensorFlow Lite for Microcontrollers interpreter expects the model to be
|
The TensorFlow Lite for Microcontrollers interpreter expects the model to be
|
||||||
provided as a C++ array. In the *Hello World* example, the model is defined in
|
provided as a C++ array. The model is defined in `model.h` and `model.cc` files.
|
||||||
`sine_model_data.h` and `sine_model_data.cc`. The header is included with the
|
The header is included with the following line:
|
||||||
following line:
|
|
||||||
|
|
||||||
```C++
|
```C++
|
||||||
#include "tensorflow/lite/micro/examples/hello_world/sine_model_data.h"
|
#include "tensorflow/lite/micro/examples/hello_world/model.h"
|
||||||
```
|
```
|
||||||
|
|
||||||
### Set up the unit test
|
### 3. Include the unit test framework header
|
||||||
|
|
||||||
The code we are walking through is a unit test that uses the TensorFlow Lite for
|
In order to create a unit test, we include the TensorFlow Lite for
|
||||||
Microcontrollers unit test framework. To load the framework, we include the
|
Microcontrollers unit test framework by including the following line:
|
||||||
following file:
|
|
||||||
|
|
||||||
```C++
|
```C++
|
||||||
#include "tensorflow/lite/micro/testing/micro_test.h"
|
#include "tensorflow/lite/micro/testing/micro_test.h"
|
||||||
|
@ -143,11 +139,16 @@ The test is defined using the following macros:
|
||||||
TF_LITE_MICRO_TESTS_BEGIN
|
TF_LITE_MICRO_TESTS_BEGIN
|
||||||
|
|
||||||
TF_LITE_MICRO_TEST(LoadModelAndPerformInference) {
|
TF_LITE_MICRO_TEST(LoadModelAndPerformInference) {
|
||||||
|
. // add code here
|
||||||
|
.
|
||||||
|
}
|
||||||
|
|
||||||
|
TF_LITE_MICRO_TESTS_END
|
||||||
```
|
```
|
||||||
|
|
||||||
The remainder of the code demonstrates how to load the model and run inference.
|
We now discuss the code included in the macro above.
|
||||||
|
|
||||||
### Set up logging
|
### 4. Set up logging
|
||||||
|
|
||||||
To set up logging, a `tflite::ErrorReporter` pointer is created using a pointer
|
To set up logging, a `tflite::ErrorReporter` pointer is created using a pointer
|
||||||
to a `tflite::MicroErrorReporter` instance:
|
to a `tflite::MicroErrorReporter` instance:
|
||||||
|
@ -162,14 +163,14 @@ logs. Since microcontrollers often have a variety of mechanisms for logging, the
|
||||||
implementation of `tflite::MicroErrorReporter` is designed to be customized for
|
implementation of `tflite::MicroErrorReporter` is designed to be customized for
|
||||||
your particular device.
|
your particular device.
|
||||||
|
|
||||||
### Load a model
|
### 5. Load a model
|
||||||
|
|
||||||
In the following code, the model is instantiated using data from a `char` array,
|
In the following code, the model is instantiated using data from a `char` array,
|
||||||
`g_sine_model_data`, which is declared in `sine_model_data.h`. We then check the
|
`g_model`, which is declared in `model.h`. We then check the model to ensure its
|
||||||
model to ensure its schema version is compatible with the version we are using:
|
schema version is compatible with the version we are using:
|
||||||
|
|
||||||
```C++
|
```C++
|
||||||
const tflite::Model* model = ::tflite::GetModel(g_sine_model_data);
|
const tflite::Model* model = ::tflite::GetModel(g_model);
|
||||||
if (model->version() != TFLITE_SCHEMA_VERSION) {
|
if (model->version() != TFLITE_SCHEMA_VERSION) {
|
||||||
TF_LITE_REPORT_ERROR(error_reporter,
|
TF_LITE_REPORT_ERROR(error_reporter,
|
||||||
"Model provided is schema version %d not equal "
|
"Model provided is schema version %d not equal "
|
||||||
|
@ -178,7 +179,7 @@ if (model->version() != TFLITE_SCHEMA_VERSION) {
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Instantiate operations resolver
|
### 6. Instantiate operations resolver
|
||||||
|
|
||||||
An
|
An
|
||||||
[`AllOpsResolver`](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/lite/micro/kernels/all_ops_resolver.h)
|
[`AllOpsResolver`](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/lite/micro/kernels/all_ops_resolver.h)
|
||||||
|
@ -198,7 +199,7 @@ This is done using a different class, `MicroMutableOpResolver`. You can see how
|
||||||
to use it in the *Micro speech* example's
|
to use it in the *Micro speech* example's
|
||||||
[`micro_speech_test.cc`](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/lite/micro/examples/micro_speech/micro_speech_test.cc).
|
[`micro_speech_test.cc`](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/lite/micro/examples/micro_speech/micro_speech_test.cc).
|
||||||
|
|
||||||
### Allocate memory
|
### 7. Allocate memory
|
||||||
|
|
||||||
We need to preallocate a certain amount of memory for input, output, and
|
We need to preallocate a certain amount of memory for input, output, and
|
||||||
intermediate arrays. This is provided as a `uint8_t` array of size
|
intermediate arrays. This is provided as a `uint8_t` array of size
|
||||||
|
@ -212,7 +213,7 @@ uint8_t tensor_arena[tensor_arena_size];
|
||||||
The size required will depend on the model you are using, and may need to be
|
The size required will depend on the model you are using, and may need to be
|
||||||
determined by experimentation.
|
determined by experimentation.
|
||||||
|
|
||||||
### Instantiate interpreter
|
### 8. Instantiate interpreter
|
||||||
|
|
||||||
We create a `tflite::MicroInterpreter` instance, passing in the variables
|
We create a `tflite::MicroInterpreter` instance, passing in the variables
|
||||||
created earlier:
|
created earlier:
|
||||||
|
@ -222,7 +223,7 @@ tflite::MicroInterpreter interpreter(model, resolver, tensor_arena,
|
||||||
tensor_arena_size, error_reporter);
|
tensor_arena_size, error_reporter);
|
||||||
```
|
```
|
||||||
|
|
||||||
### Allocate tensors
|
### 9. Allocate tensors
|
||||||
|
|
||||||
We tell the interpreter to allocate memory from the `tensor_arena` for the
|
We tell the interpreter to allocate memory from the `tensor_arena` for the
|
||||||
model's tensors:
|
model's tensors:
|
||||||
|
@ -231,7 +232,7 @@ model's tensors:
|
||||||
interpreter.AllocateTensors();
|
interpreter.AllocateTensors();
|
||||||
```
|
```
|
||||||
|
|
||||||
### Validate input shape
|
### 10. Validate input shape
|
||||||
|
|
||||||
The `MicroInterpreter` instance can provide us with a pointer to the model's
|
The `MicroInterpreter` instance can provide us with a pointer to the model's
|
||||||
input tensor by calling `.input(0)`, where `0` represents the first (and only)
|
input tensor by calling `.input(0)`, where `0` represents the first (and only)
|
||||||
|
@ -265,7 +266,7 @@ The enum value `kTfLiteFloat32` is a reference to one of the TensorFlow Lite
|
||||||
data types, and is defined in
|
data types, and is defined in
|
||||||
[`common.h`](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/lite/c/common.h).
|
[`common.h`](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/lite/c/common.h).
|
||||||
|
|
||||||
### Provide an input value
|
### 11. Provide an input value
|
||||||
|
|
||||||
To provide an input to the model, we set the contents of the input tensor, as
|
To provide an input to the model, we set the contents of the input tensor, as
|
||||||
follows:
|
follows:
|
||||||
|
@ -276,7 +277,7 @@ input->data.f[0] = 0.;
|
||||||
|
|
||||||
In this case, we input a floating point value representing `0`.
|
In this case, we input a floating point value representing `0`.
|
||||||
|
|
||||||
### Run the model
|
### 12. Run the model
|
||||||
|
|
||||||
To run the model, we can call `Invoke()` on our `tflite::MicroInterpreter`
|
To run the model, we can call `Invoke()` on our `tflite::MicroInterpreter`
|
||||||
instance:
|
instance:
|
||||||
|
@ -300,7 +301,7 @@ successfully run.
|
||||||
TF_LITE_MICRO_EXPECT_EQ(kTfLiteOk, invoke_status);
|
TF_LITE_MICRO_EXPECT_EQ(kTfLiteOk, invoke_status);
|
||||||
```
|
```
|
||||||
|
|
||||||
### Obtain the output
|
### 12. Obtain the output
|
||||||
|
|
||||||
The model's output tensor can be obtained by calling `output(0)` on the
|
The model's output tensor can be obtained by calling `output(0)` on the
|
||||||
`tflite::MicroInterpreter`, where `0` represents the first (and only) output
|
`tflite::MicroInterpreter`, where `0` represents the first (and only) output
|
||||||
|
@ -327,7 +328,7 @@ float value = output->data.f[0];
|
||||||
TF_LITE_MICRO_EXPECT_NEAR(0., value, 0.05);
|
TF_LITE_MICRO_EXPECT_NEAR(0., value, 0.05);
|
||||||
```
|
```
|
||||||
|
|
||||||
### Run inference again
|
### 13. Run inference again
|
||||||
|
|
||||||
The remainder of the code runs inference several more times. In each instance,
|
The remainder of the code runs inference several more times. In each instance,
|
||||||
we assign a value to the input tensor, invoke the interpreter, and read the
|
we assign a value to the input tensor, invoke the interpreter, and read the
|
||||||
|
@ -350,7 +351,7 @@ value = output->data.f[0];
|
||||||
TF_LITE_MICRO_EXPECT_NEAR(-0.959, value, 0.05);
|
TF_LITE_MICRO_EXPECT_NEAR(-0.959, value, 0.05);
|
||||||
```
|
```
|
||||||
|
|
||||||
### Read the application code
|
### 14. Read the application code
|
||||||
|
|
||||||
Once you have walked through this unit test, you should be able to understand
|
Once you have walked through this unit test, you should be able to understand
|
||||||
the example's application code, located in
|
the example's application code, located in
|
||||||
|
|
|
@ -16,12 +16,12 @@ package(default_visibility = ["//visibility:public"])
|
||||||
licenses(["notice"]) # Apache 2.0
|
licenses(["notice"]) # Apache 2.0
|
||||||
|
|
||||||
cc_library(
|
cc_library(
|
||||||
name = "sine_model_data",
|
name = "model",
|
||||||
srcs = [
|
srcs = [
|
||||||
"sine_model_data.cc",
|
"model.cc",
|
||||||
],
|
],
|
||||||
hdrs = [
|
hdrs = [
|
||||||
"sine_model_data.h",
|
"model.h",
|
||||||
],
|
],
|
||||||
build_for_embedded = True,
|
build_for_embedded = True,
|
||||||
copts = micro_copts(),
|
copts = micro_copts(),
|
||||||
|
@ -33,9 +33,9 @@ tflite_micro_cc_test(
|
||||||
"hello_world_test.cc",
|
"hello_world_test.cc",
|
||||||
],
|
],
|
||||||
deps = [
|
deps = [
|
||||||
|
":model",
|
||||||
"//tensorflow/lite:schema_fbs_version",
|
"//tensorflow/lite:schema_fbs_version",
|
||||||
"//tensorflow/lite/micro:micro_framework",
|
"//tensorflow/lite/micro:micro_framework",
|
||||||
"//tensorflow/lite/micro/examples/hello_world:sine_model_data",
|
|
||||||
"//tensorflow/lite/micro/kernels:all_ops_resolver",
|
"//tensorflow/lite/micro/kernels:all_ops_resolver",
|
||||||
"//tensorflow/lite/micro/kernels:micro_ops",
|
"//tensorflow/lite/micro/kernels:micro_ops",
|
||||||
"//tensorflow/lite/micro/testing:micro_test",
|
"//tensorflow/lite/micro/testing:micro_test",
|
||||||
|
@ -83,10 +83,10 @@ cc_binary(
|
||||||
],
|
],
|
||||||
deps = [
|
deps = [
|
||||||
":constants",
|
":constants",
|
||||||
|
":model",
|
||||||
":output_handler",
|
":output_handler",
|
||||||
"//tensorflow/lite:schema_fbs_version",
|
"//tensorflow/lite:schema_fbs_version",
|
||||||
"//tensorflow/lite/micro:micro_framework",
|
"//tensorflow/lite/micro:micro_framework",
|
||||||
"//tensorflow/lite/micro/examples/hello_world:sine_model_data",
|
|
||||||
"//tensorflow/lite/micro/kernels:all_ops_resolver",
|
"//tensorflow/lite/micro/kernels:all_ops_resolver",
|
||||||
"//tensorflow/lite/schema:schema_fbs",
|
"//tensorflow/lite/schema:schema_fbs",
|
||||||
],
|
],
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
HELLO_WORLD_TEST_SRCS := \
|
HELLO_WORLD_TEST_SRCS := \
|
||||||
tensorflow/lite/micro/examples/hello_world/hello_world_test.cc \
|
tensorflow/lite/micro/examples/hello_world/hello_world_test.cc \
|
||||||
tensorflow/lite/micro/examples/hello_world/sine_model_data.cc
|
tensorflow/lite/micro/examples/hello_world/model.cc
|
||||||
|
|
||||||
HELLO_WORLD_TEST_HDRS := \
|
HELLO_WORLD_TEST_HDRS := \
|
||||||
tensorflow/lite/micro/examples/hello_world/sine_model_data.h
|
tensorflow/lite/micro/examples/hello_world/model.h
|
||||||
|
|
||||||
OUTPUT_HANDLER_TEST_SRCS := \
|
OUTPUT_HANDLER_TEST_SRCS := \
|
||||||
tensorflow/lite/micro/examples/hello_world/output_handler_test.cc \
|
tensorflow/lite/micro/examples/hello_world/output_handler_test.cc \
|
||||||
|
@ -16,12 +16,12 @@ tensorflow/lite/micro/examples/hello_world/constants.h
|
||||||
HELLO_WORLD_SRCS := \
|
HELLO_WORLD_SRCS := \
|
||||||
tensorflow/lite/micro/examples/hello_world/main.cc \
|
tensorflow/lite/micro/examples/hello_world/main.cc \
|
||||||
tensorflow/lite/micro/examples/hello_world/main_functions.cc \
|
tensorflow/lite/micro/examples/hello_world/main_functions.cc \
|
||||||
tensorflow/lite/micro/examples/hello_world/sine_model_data.cc \
|
tensorflow/lite/micro/examples/hello_world/model.cc \
|
||||||
tensorflow/lite/micro/examples/hello_world/output_handler.cc \
|
tensorflow/lite/micro/examples/hello_world/output_handler.cc \
|
||||||
tensorflow/lite/micro/examples/hello_world/constants.cc
|
tensorflow/lite/micro/examples/hello_world/constants.cc
|
||||||
|
|
||||||
HELLO_WORLD_HDRS := \
|
HELLO_WORLD_HDRS := \
|
||||||
tensorflow/lite/micro/examples/hello_world/sine_model_data.h \
|
tensorflow/lite/micro/examples/hello_world/model.h \
|
||||||
tensorflow/lite/micro/examples/hello_world/output_handler.h \
|
tensorflow/lite/micro/examples/hello_world/output_handler.h \
|
||||||
tensorflow/lite/micro/examples/hello_world/constants.h \
|
tensorflow/lite/micro/examples/hello_world/constants.h \
|
||||||
tensorflow/lite/micro/examples/hello_world/main_functions.h
|
tensorflow/lite/micro/examples/hello_world/main_functions.h
|
||||||
|
|
|
@ -1,41 +1,32 @@
|
||||||
# Hello World example
|
# Hello World Example
|
||||||
|
|
||||||
This example is designed to demonstrate the absolute basics of using [TensorFlow
|
This example is designed to demonstrate the absolute basics of using [TensorFlow
|
||||||
Lite for Microcontrollers](https://www.tensorflow.org/lite/microcontrollers).
|
Lite for Microcontrollers](https://www.tensorflow.org/lite/microcontrollers).
|
||||||
It includes the full end-to-end workflow of training a model, converting it for
|
It includes the full end-to-end workflow of training a model, converting it for
|
||||||
use with TensorFlow Lite, and running inference on a microcontroller.
|
use with TensorFlow Lite for Microcontrollers for running inference on a
|
||||||
|
microcontroller.
|
||||||
|
|
||||||
The sample is built around a model trained to replicate a `sine` function. It
|
The model is trained to replicate a `sine` function and generates a pattern of
|
||||||
contains implementations for several platforms. In each case, the model is used
|
data to either blink LEDs or control an animation, depending on the capabilities
|
||||||
to generate a pattern of data that is used to either blink LEDs or control an
|
of the device.
|
||||||
animation.
|
|
||||||
|
|
||||||
![Animation of example running on STM32F746](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/lite/micro/examples/hello_world/images/STM32F746.gif)
|
![Animation on STM32F746](images/animation_on_STM32F746.gif)
|
||||||
|
|
||||||
## Table of contents
|
## Table of contents
|
||||||
|
|
||||||
- [Understand the model](#understand-the-model)
|
|
||||||
- [Deploy to Arduino](#deploy-to-arduino)
|
- [Deploy to Arduino](#deploy-to-arduino)
|
||||||
- [Deploy to ESP32](#deploy-to-esp32)
|
- [Deploy to ESP32](#deploy-to-esp32)
|
||||||
- [Deploy to SparkFun Edge](#deploy-to-sparkfun-edge)
|
- [Deploy to SparkFun Edge](#deploy-to-sparkfun-edge)
|
||||||
- [Deploy to STM32F746](#deploy-to-STM32F746)
|
- [Deploy to STM32F746](#deploy-to-STM32F746)
|
||||||
- [Run the tests on a development machine](#run-the-tests-on-a-development-machine)
|
- [Run the tests on a development machine](#run-the-tests-on-a-development-machine)
|
||||||
|
- [Train your own model](#train-your-own-model)
|
||||||
## Understand the model
|
|
||||||
|
|
||||||
The sample comes with a pre-trained model. The code used to train and convert
|
|
||||||
the model is available as a tutorial in [create_sine_model.ipynb](https://colab.research.google.com/github/tensorflow/tensorflow/blob/master/tensorflow/lite/micro/examples/hello_world/create_sine_model.ipynb).
|
|
||||||
|
|
||||||
Walk through this tutorial to understand what the model does,
|
|
||||||
how it works, and how it was converted for use with TensorFlow Lite for
|
|
||||||
Microcontrollers.
|
|
||||||
|
|
||||||
## Deploy to Arduino
|
## Deploy to Arduino
|
||||||
|
|
||||||
The following instructions will help you build and deploy this sample
|
The following instructions will help you build and deploy this sample
|
||||||
to [Arduino](https://www.arduino.cc/) devices.
|
to [Arduino](https://www.arduino.cc/) devices.
|
||||||
|
|
||||||
![Animation of example running on Arduino MKRZERO](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/lite/micro/examples/hello_world/images/arduino_mkrzero.gif)
|
![Animation on Arduino MKRZERO](images/animation_on_arduino_mkrzero.gif)
|
||||||
|
|
||||||
The sample has been tested with the following devices:
|
The sample has been tested with the following devices:
|
||||||
|
|
||||||
|
@ -132,7 +123,7 @@ idf.py --port /dev/ttyUSB0 flash monitor
|
||||||
The following instructions will help you build and deploy this sample on the
|
The following instructions will help you build and deploy this sample on the
|
||||||
[SparkFun Edge development board](https://sparkfun.com/products/15170).
|
[SparkFun Edge development board](https://sparkfun.com/products/15170).
|
||||||
|
|
||||||
![Animation of example running on SparkFun Edge](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/lite/micro/examples/hello_world/images/sparkfun_edge.gif)
|
![Animation on SparkFun Edge](images/animation_on_sparkfun_edge.gif)
|
||||||
|
|
||||||
If you're new to using this board, we recommend walking through the
|
If you're new to using this board, we recommend walking through the
|
||||||
[AI on a microcontroller with TensorFlow Lite and SparkFun Edge](https://codelabs.developers.google.com/codelabs/sparkfun-tensorflow)
|
[AI on a microcontroller with TensorFlow Lite and SparkFun Edge](https://codelabs.developers.google.com/codelabs/sparkfun-tensorflow)
|
||||||
|
@ -272,7 +263,7 @@ The following instructions will help you build and deploy the sample to the
|
||||||
[STM32F7 discovery kit](https://os.mbed.com/platforms/ST-Discovery-F746NG/)
|
[STM32F7 discovery kit](https://os.mbed.com/platforms/ST-Discovery-F746NG/)
|
||||||
using [ARM Mbed](https://github.com/ARMmbed/mbed-cli).
|
using [ARM Mbed](https://github.com/ARMmbed/mbed-cli).
|
||||||
|
|
||||||
![Animation of example running on STM32F746](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/lite/micro/examples/hello_world/images/STM32F746.gif)
|
![Animation on STM32F746](images/animation_on_STM32F746.gif)
|
||||||
|
|
||||||
Before we begin, you'll need the following:
|
Before we begin, you'll need the following:
|
||||||
|
|
||||||
|
@ -400,7 +391,14 @@ the trained TensorFlow model, runs some example inputs through it, and got the
|
||||||
expected outputs.
|
expected outputs.
|
||||||
|
|
||||||
To understand how TensorFlow Lite does this, you can look at the source in
|
To understand how TensorFlow Lite does this, you can look at the source in
|
||||||
[hello_world_test.cc](https://github.com/tensorflow/tensorflow/tree/master/tensorflow/lite/micro/examples/hello_world/hello_world_test.cc).
|
[hello_world_test.cc](hello_world_test.cc).
|
||||||
It's a fairly small amount of code that creates an interpreter, gets a handle to
|
It's a fairly small amount of code that creates an interpreter, gets a handle to
|
||||||
a model that's been compiled into the program, and then invokes the interpreter
|
a model that's been compiled into the program, and then invokes the interpreter
|
||||||
with the model and sample inputs.
|
with the model and sample inputs.
|
||||||
|
|
||||||
|
### Train your own model
|
||||||
|
|
||||||
|
So far you have used an existing trained model to run inference on
|
||||||
|
microcontrollers. If you wish to train your own model, follow the instructions
|
||||||
|
given in the [train/](train/) directory.
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ limitations under the License.
|
||||||
==============================================================================*/
|
==============================================================================*/
|
||||||
|
|
||||||
// #include "tensorflow/lite/c/common.h"
|
// #include "tensorflow/lite/c/common.h"
|
||||||
#include "tensorflow/lite/micro/examples/hello_world/sine_model_data.h"
|
#include "tensorflow/lite/micro/examples/hello_world/model.h"
|
||||||
#include "tensorflow/lite/micro/kernels/all_ops_resolver.h"
|
#include "tensorflow/lite/micro/kernels/all_ops_resolver.h"
|
||||||
#include "tensorflow/lite/micro/micro_error_reporter.h"
|
#include "tensorflow/lite/micro/micro_error_reporter.h"
|
||||||
#include "tensorflow/lite/micro/micro_interpreter.h"
|
#include "tensorflow/lite/micro/micro_interpreter.h"
|
||||||
|
@ -31,7 +31,7 @@ TF_LITE_MICRO_TEST(LoadModelAndPerformInference) {
|
||||||
|
|
||||||
// Map the model into a usable data structure. This doesn't involve any
|
// Map the model into a usable data structure. This doesn't involve any
|
||||||
// copying or parsing, it's a very lightweight operation.
|
// copying or parsing, it's a very lightweight operation.
|
||||||
const tflite::Model* model = ::tflite::GetModel(g_sine_model_data);
|
const tflite::Model* model = ::tflite::GetModel(g_model);
|
||||||
if (model->version() != TFLITE_SCHEMA_VERSION) {
|
if (model->version() != TFLITE_SCHEMA_VERSION) {
|
||||||
TF_LITE_REPORT_ERROR(error_reporter,
|
TF_LITE_REPORT_ERROR(error_reporter,
|
||||||
"Model provided is schema version %d not equal "
|
"Model provided is schema version %d not equal "
|
||||||
|
@ -43,8 +43,13 @@ TF_LITE_MICRO_TEST(LoadModelAndPerformInference) {
|
||||||
tflite::ops::micro::AllOpsResolver resolver;
|
tflite::ops::micro::AllOpsResolver resolver;
|
||||||
|
|
||||||
// Create an area of memory to use for input, output, and intermediate arrays.
|
// Create an area of memory to use for input, output, and intermediate arrays.
|
||||||
// `arena_used_bytes` can be used to retrieve the optimal size.
|
|
||||||
const int tensor_arena_size = 2208 + 16 + 100 /* some reserved space */;
|
// Minimum arena size, at the time of writing. After allocating tensors
|
||||||
|
// you can retrieve this value by invoking interpreter.arena_used_bytes().
|
||||||
|
const int model_arena_size = 2352;
|
||||||
|
/* Extra headroom for model + alignment + future interpreter changes */
|
||||||
|
const int extra_arena_size = 560 + 16 + 100;
|
||||||
|
const int tensor_arena_size = model_arena_size + extra_arena_size;
|
||||||
uint8_t tensor_arena[tensor_arena_size];
|
uint8_t tensor_arena[tensor_arena_size];
|
||||||
|
|
||||||
// Build an interpreter to run the model with
|
// Build an interpreter to run the model with
|
||||||
|
@ -53,11 +58,10 @@ TF_LITE_MICRO_TEST(LoadModelAndPerformInference) {
|
||||||
|
|
||||||
// Allocate memory from the tensor_arena for the model's tensors
|
// Allocate memory from the tensor_arena for the model's tensors
|
||||||
TF_LITE_MICRO_EXPECT_EQ(interpreter.AllocateTensors(), kTfLiteOk);
|
TF_LITE_MICRO_EXPECT_EQ(interpreter.AllocateTensors(), kTfLiteOk);
|
||||||
// At the time of writing, the hello world model uses 2208 bytes, we leave
|
|
||||||
// 100 bytes head room here to make the test less fragile and in the same
|
|
||||||
// time, alert for substantial increase.
|
|
||||||
TF_LITE_MICRO_EXPECT_LE(interpreter.arena_used_bytes(), 2208 + 100);
|
|
||||||
|
|
||||||
|
// Alert for substantial increase in arena size usage.
|
||||||
|
TF_LITE_MICRO_EXPECT_LE(interpreter.arena_used_bytes(),
|
||||||
|
model_arena_size + 100);
|
||||||
// Obtain a pointer to the model's input tensor
|
// Obtain a pointer to the model's input tensor
|
||||||
TfLiteTensor* input = interpreter.input(0);
|
TfLiteTensor* input = interpreter.input(0);
|
||||||
|
|
||||||
|
|
Before Width: | Height: | Size: 292 KiB After Width: | Height: | Size: 292 KiB |
Before Width: | Height: | Size: 529 KiB After Width: | Height: | Size: 529 KiB |
Before Width: | Height: | Size: 625 KiB After Width: | Height: | Size: 625 KiB |
After Width: | Height: | Size: 89 KiB |
|
@ -1,4 +1,4 @@
|
||||||
/* Copyright 2019 The TensorFlow Authors. All Rights Reserved.
|
/* Copyright 2020 The TensorFlow Authors. All Rights Reserved.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
@ -16,8 +16,8 @@ limitations under the License.
|
||||||
#include "tensorflow/lite/micro/examples/hello_world/main_functions.h"
|
#include "tensorflow/lite/micro/examples/hello_world/main_functions.h"
|
||||||
|
|
||||||
#include "tensorflow/lite/micro/examples/hello_world/constants.h"
|
#include "tensorflow/lite/micro/examples/hello_world/constants.h"
|
||||||
|
#include "tensorflow/lite/micro/examples/hello_world/model.h"
|
||||||
#include "tensorflow/lite/micro/examples/hello_world/output_handler.h"
|
#include "tensorflow/lite/micro/examples/hello_world/output_handler.h"
|
||||||
#include "tensorflow/lite/micro/examples/hello_world/sine_model_data.h"
|
|
||||||
#include "tensorflow/lite/micro/kernels/all_ops_resolver.h"
|
#include "tensorflow/lite/micro/kernels/all_ops_resolver.h"
|
||||||
#include "tensorflow/lite/micro/micro_error_reporter.h"
|
#include "tensorflow/lite/micro/micro_error_reporter.h"
|
||||||
#include "tensorflow/lite/micro/micro_interpreter.h"
|
#include "tensorflow/lite/micro/micro_interpreter.h"
|
||||||
|
@ -49,7 +49,7 @@ void setup() {
|
||||||
|
|
||||||
// Map the model into a usable data structure. This doesn't involve any
|
// Map the model into a usable data structure. This doesn't involve any
|
||||||
// copying or parsing, it's a very lightweight operation.
|
// copying or parsing, it's a very lightweight operation.
|
||||||
model = tflite::GetModel(g_sine_model_data);
|
model = tflite::GetModel(g_model);
|
||||||
if (model->version() != TFLITE_SCHEMA_VERSION) {
|
if (model->version() != TFLITE_SCHEMA_VERSION) {
|
||||||
TF_LITE_REPORT_ERROR(error_reporter,
|
TF_LITE_REPORT_ERROR(error_reporter,
|
||||||
"Model provided is schema version %d not equal "
|
"Model provided is schema version %d not equal "
|
||||||
|
|
|
@ -0,0 +1,250 @@
|
||||||
|
/* Copyright 2020 The TensorFlow Authors. All Rights Reserved.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
==============================================================================*/
|
||||||
|
|
||||||
|
// Automatically created from a TensorFlow Lite flatbuffer using the command:
|
||||||
|
// xxd -i model.tflite > model.cc
|
||||||
|
|
||||||
|
// This is a standard TensorFlow Lite model file that has been converted into a
|
||||||
|
// C data array, so it can be easily compiled into a binary for devices that
|
||||||
|
// don't have a file system.
|
||||||
|
|
||||||
|
// See train/README.md for a full description of the creation process.
|
||||||
|
|
||||||
|
#include "tensorflow/lite/micro/examples/hello_world/model.h"
|
||||||
|
|
||||||
|
// We need to keep the data array aligned on some architectures.
|
||||||
|
#ifdef __has_attribute
|
||||||
|
#define HAVE_ATTRIBUTE(x) __has_attribute(x)
|
||||||
|
#else
|
||||||
|
#define HAVE_ATTRIBUTE(x) 0
|
||||||
|
#endif
|
||||||
|
#if HAVE_ATTRIBUTE(aligned) || (defined(__GNUC__) && !defined(__clang__))
|
||||||
|
#define DATA_ALIGN_ATTRIBUTE __attribute__((aligned(4)))
|
||||||
|
#else
|
||||||
|
#define DATA_ALIGN_ATTRIBUTE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
const unsigned char g_model[] DATA_ALIGN_ATTRIBUTE = {
|
||||||
|
0x1c, 0x00, 0x00, 0x00, 0x54, 0x46, 0x4c, 0x33, 0x00, 0x00, 0x12, 0x00,
|
||||||
|
0x1c, 0x00, 0x04, 0x00, 0x08, 0x00, 0x0c, 0x00, 0x10, 0x00, 0x14, 0x00,
|
||||||
|
0x00, 0x00, 0x18, 0x00, 0x12, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
|
||||||
|
0x60, 0x09, 0x00, 0x00, 0xa8, 0x02, 0x00, 0x00, 0x90, 0x02, 0x00, 0x00,
|
||||||
|
0x3c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
||||||
|
0x0c, 0x00, 0x00, 0x00, 0x08, 0x00, 0x0c, 0x00, 0x04, 0x00, 0x08, 0x00,
|
||||||
|
0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00,
|
||||||
|
0x13, 0x00, 0x00, 0x00, 0x6d, 0x69, 0x6e, 0x5f, 0x72, 0x75, 0x6e, 0x74,
|
||||||
|
0x69, 0x6d, 0x65, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x00,
|
||||||
|
0x0c, 0x00, 0x00, 0x00, 0x48, 0x02, 0x00, 0x00, 0x34, 0x02, 0x00, 0x00,
|
||||||
|
0x0c, 0x02, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0xac, 0x00, 0x00, 0x00,
|
||||||
|
0x8c, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00,
|
||||||
|
0x2c, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00,
|
||||||
|
0x04, 0x00, 0x00, 0x00, 0xfe, 0xfd, 0xff, 0xff, 0x04, 0x00, 0x00, 0x00,
|
||||||
|
0x05, 0x00, 0x00, 0x00, 0x31, 0x2e, 0x35, 0x2e, 0x30, 0x00, 0x00, 0x00,
|
||||||
|
0x7c, 0xfd, 0xff, 0xff, 0x80, 0xfd, 0xff, 0xff, 0x84, 0xfd, 0xff, 0xff,
|
||||||
|
0x88, 0xfd, 0xff, 0xff, 0x22, 0xfe, 0xff, 0xff, 0x04, 0x00, 0x00, 0x00,
|
||||||
|
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x04, 0x00, 0x00,
|
||||||
|
0x9f, 0x0a, 0x00, 0x00, 0x65, 0x06, 0x00, 0x00, 0x3d, 0xf8, 0xff, 0xff,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0xeb, 0x0a, 0x00, 0x00, 0x2f, 0xf8, 0xff, 0xff,
|
||||||
|
0xe8, 0x04, 0x00, 0x00, 0x21, 0x0a, 0x00, 0x00, 0x46, 0xfe, 0xff, 0xff,
|
||||||
|
0xc8, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa3, 0xf7, 0xff, 0xff,
|
||||||
|
0x28, 0xf9, 0xff, 0xff, 0x9a, 0x05, 0x00, 0x00, 0x6e, 0xfe, 0xff, 0xff,
|
||||||
|
0x04, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x73, 0x1c, 0x11, 0xe1,
|
||||||
|
0x0c, 0x81, 0xa5, 0x43, 0xfe, 0xd5, 0xd5, 0xb2, 0x60, 0x77, 0x19, 0xdf,
|
||||||
|
0x8a, 0xfe, 0xff, 0xff, 0x04, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00,
|
||||||
|
0x01, 0x00, 0x00, 0x00, 0x51, 0x0b, 0x00, 0x00, 0x47, 0xf6, 0xff, 0xff,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x1c, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x9b, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0xe7, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x92, 0x07, 0x00, 0x00, 0xf4, 0xf4, 0xff, 0xff, 0x55, 0xf0, 0xff, 0xff,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0xd6, 0xfe, 0xff, 0xff, 0x04, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x01, 0x00, 0x00, 0xee, 0xfc, 0x00, 0xec, 0x05, 0x16, 0xef, 0xec,
|
||||||
|
0xe6, 0xf8, 0x03, 0x01, 0x00, 0xfa, 0xf8, 0xf5, 0xda, 0xeb, 0x27, 0x14,
|
||||||
|
0xef, 0xde, 0xe2, 0xda, 0xf0, 0xdf, 0x32, 0x06, 0x01, 0xe6, 0xee, 0xf9,
|
||||||
|
0x00, 0x16, 0x07, 0xe0, 0xfe, 0xff, 0xe9, 0x05, 0xe7, 0xef, 0x81, 0x1b,
|
||||||
|
0x18, 0xea, 0xca, 0x01, 0x0f, 0x00, 0xdb, 0xf7, 0x0e, 0xec, 0x12, 0x1e,
|
||||||
|
0x04, 0x13, 0xb2, 0xe7, 0xfd, 0x06, 0xbb, 0xe0, 0x0c, 0xec, 0xf0, 0xdf,
|
||||||
|
0xeb, 0xf7, 0x05, 0x26, 0x19, 0xe4, 0x70, 0x1a, 0xea, 0x1e, 0x34, 0xdf,
|
||||||
|
0x19, 0xf3, 0xf1, 0x19, 0x0e, 0x03, 0x1b, 0xe1, 0xde, 0x13, 0xf6, 0x19,
|
||||||
|
0xff, 0xf6, 0x1a, 0x17, 0xf1, 0x1c, 0xdb, 0x1a, 0x1a, 0x20, 0xe6, 0x19,
|
||||||
|
0xf5, 0xff, 0x97, 0x0b, 0x00, 0x00, 0xce, 0xdf, 0x0d, 0xf7, 0x15, 0xe4,
|
||||||
|
0xed, 0xfc, 0x0d, 0xe9, 0xfb, 0xec, 0x5c, 0xfc, 0x1d, 0x02, 0x58, 0xe3,
|
||||||
|
0xe0, 0xf4, 0x15, 0xec, 0xf9, 0x00, 0x13, 0x05, 0xec, 0x0c, 0x1c, 0x14,
|
||||||
|
0x0c, 0xe9, 0x0a, 0xf4, 0x18, 0x00, 0xd7, 0x05, 0x27, 0x02, 0x15, 0xea,
|
||||||
|
0xea, 0x02, 0x9b, 0x00, 0x0c, 0xfa, 0xe9, 0xea, 0xfe, 0x01, 0x14, 0xfd,
|
||||||
|
0x0b, 0x02, 0xf0, 0xef, 0x06, 0xee, 0x01, 0x0d, 0x06, 0xe7, 0xf7, 0x11,
|
||||||
|
0xf5, 0x0a, 0xf9, 0xf1, 0x23, 0xff, 0x0d, 0xf2, 0xec, 0x11, 0x26, 0x1d,
|
||||||
|
0xf2, 0xea, 0x28, 0x18, 0xe0, 0xfb, 0xf3, 0xf4, 0x05, 0x1c, 0x1d, 0xfb,
|
||||||
|
0xfd, 0x1e, 0xfc, 0x11, 0xe8, 0x06, 0x09, 0x03, 0x12, 0xf2, 0x35, 0xfb,
|
||||||
|
0xdd, 0x1b, 0xf9, 0xef, 0xf3, 0xe7, 0x6f, 0x0c, 0x1d, 0x00, 0x43, 0xfd,
|
||||||
|
0x0d, 0xf1, 0x0a, 0x19, 0x1a, 0xfa, 0xe0, 0x18, 0x1e, 0x13, 0x37, 0x1c,
|
||||||
|
0x12, 0xec, 0x3a, 0x0c, 0xb6, 0xcb, 0xe6, 0x13, 0xf7, 0xeb, 0xf1, 0x05,
|
||||||
|
0x1b, 0xfa, 0x19, 0xe5, 0xec, 0xcf, 0x0c, 0xf4, 0xe2, 0xff, 0xff, 0xff,
|
||||||
|
0x04, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x21, 0xa2, 0x8c, 0xc9,
|
||||||
|
0x5f, 0x1d, 0xce, 0x41, 0x9f, 0xcd, 0x20, 0xb1, 0xdf, 0x53, 0x2f, 0x81,
|
||||||
|
0x00, 0x00, 0x06, 0x00, 0x08, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00,
|
||||||
|
0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0xe2, 0xee, 0xff, 0xff,
|
||||||
|
0x80, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x54, 0x4f, 0x43, 0x4f,
|
||||||
|
0x20, 0x43, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x74, 0x65, 0x64, 0x2e, 0x00,
|
||||||
|
0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0xbc, 0xf9, 0xff, 0xff,
|
||||||
|
0x48, 0x01, 0x00, 0x00, 0x3c, 0x01, 0x00, 0x00, 0x30, 0x01, 0x00, 0x00,
|
||||||
|
0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x04, 0x01, 0x00, 0x00,
|
||||||
|
0xb8, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00,
|
||||||
|
0x04, 0x00, 0x00, 0x00, 0x1a, 0xff, 0xff, 0xff, 0x02, 0x00, 0x00, 0x00,
|
||||||
|
0x10, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
||||||
|
0x0b, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0xca, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x08, 0x1c, 0x00, 0x00, 0x00,
|
||||||
|
0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x04, 0x00,
|
||||||
|
0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x03, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
|
||||||
|
0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x14, 0x00, 0x00, 0x00,
|
||||||
|
0x08, 0x00, 0x0c, 0x00, 0x07, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x08, 0x1c, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
|
||||||
|
0x04, 0x00, 0x00, 0x00, 0xba, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x01,
|
||||||
|
0x01, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
|
||||||
|
0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x0e, 0x00, 0x16, 0x00, 0x00, 0x00, 0x08, 0x00, 0x0c, 0x00,
|
||||||
|
0x07, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08,
|
||||||
|
0x24, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x06, 0x00, 0x08, 0x00, 0x07, 0x00, 0x06, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
|
||||||
|
0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
|
||||||
|
0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x10, 0x00, 0x04, 0x00,
|
||||||
|
0x08, 0x00, 0x0c, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
||||||
|
0x10, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
||||||
|
0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00,
|
||||||
|
0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
||||||
|
0x0a, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0xdc, 0x04, 0x00, 0x00,
|
||||||
|
0x54, 0x04, 0x00, 0x00, 0xc4, 0x03, 0x00, 0x00, 0x54, 0x03, 0x00, 0x00,
|
||||||
|
0xd0, 0x02, 0x00, 0x00, 0x4c, 0x02, 0x00, 0x00, 0xe0, 0x01, 0x00, 0x00,
|
||||||
|
0x5c, 0x01, 0x00, 0x00, 0xd8, 0x00, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00,
|
||||||
|
0x3c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0xd8, 0xff, 0xff, 0xff,
|
||||||
|
0x18, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
|
||||||
|
0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
||||||
|
0x0c, 0x00, 0x0c, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00,
|
||||||
|
0x0c, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
|
||||||
|
0x0d, 0x00, 0x00, 0x00, 0x64, 0x65, 0x6e, 0x73, 0x65, 0x5f, 0x32, 0x5f,
|
||||||
|
0x69, 0x6e, 0x70, 0x75, 0x74, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
|
||||||
|
0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xc2, 0xfb, 0xff, 0xff,
|
||||||
|
0x00, 0x00, 0x00, 0x02, 0x58, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
||||||
|
0x28, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0xc4, 0xfc, 0xff, 0xff,
|
||||||
|
0x14, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
||||||
|
0xba, 0x2b, 0x4f, 0x38, 0x20, 0x00, 0x00, 0x00, 0x73, 0x65, 0x71, 0x75,
|
||||||
|
0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x5f, 0x31, 0x2f, 0x64, 0x65, 0x6e,
|
||||||
|
0x73, 0x65, 0x5f, 0x34, 0x2f, 0x4d, 0x61, 0x74, 0x4d, 0x75, 0x6c, 0x5f,
|
||||||
|
0x62, 0x69, 0x61, 0x73, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
||||||
|
0x01, 0x00, 0x00, 0x00, 0x2a, 0xfc, 0xff, 0xff, 0x00, 0x00, 0x00, 0x09,
|
||||||
|
0x6c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00,
|
||||||
|
0x04, 0x00, 0x00, 0x00, 0x2c, 0xfd, 0xff, 0xff, 0x14, 0x00, 0x00, 0x00,
|
||||||
|
0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xb9, 0x36, 0x0b, 0x3c,
|
||||||
|
0x34, 0x00, 0x00, 0x00, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x74, 0x69,
|
||||||
|
0x61, 0x6c, 0x5f, 0x31, 0x2f, 0x64, 0x65, 0x6e, 0x73, 0x65, 0x5f, 0x34,
|
||||||
|
0x2f, 0x4d, 0x61, 0x74, 0x4d, 0x75, 0x6c, 0x2f, 0x52, 0x65, 0x61, 0x64,
|
||||||
|
0x56, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x4f, 0x70, 0x2f, 0x74,
|
||||||
|
0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x73, 0x65, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
|
||||||
|
0xaa, 0xfc, 0xff, 0xff, 0x00, 0x00, 0x00, 0x09, 0x6c, 0x00, 0x00, 0x00,
|
||||||
|
0x09, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
|
||||||
|
0x9c, 0xfc, 0xff, 0xff, 0x30, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00,
|
||||||
|
0x18, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
||||||
|
0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x01, 0x00, 0x00, 0x00, 0xaa, 0x7b, 0xbe, 0x3b, 0x01, 0x00, 0x00, 0x00,
|
||||||
|
0x2e, 0xbd, 0xbd, 0x3f, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x19, 0x00, 0x00, 0x00, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x74, 0x69,
|
||||||
|
0x61, 0x6c, 0x5f, 0x31, 0x2f, 0x64, 0x65, 0x6e, 0x73, 0x65, 0x5f, 0x33,
|
||||||
|
0x2f, 0x52, 0x65, 0x6c, 0x75, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
|
||||||
|
0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x2a, 0xfd, 0xff, 0xff,
|
||||||
|
0x00, 0x00, 0x00, 0x02, 0x58, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
|
||||||
|
0x28, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x2c, 0xfe, 0xff, 0xff,
|
||||||
|
0x14, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
||||||
|
0xe3, 0x04, 0x20, 0x39, 0x20, 0x00, 0x00, 0x00, 0x73, 0x65, 0x71, 0x75,
|
||||||
|
0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x5f, 0x31, 0x2f, 0x64, 0x65, 0x6e,
|
||||||
|
0x73, 0x65, 0x5f, 0x33, 0x2f, 0x4d, 0x61, 0x74, 0x4d, 0x75, 0x6c, 0x5f,
|
||||||
|
0x62, 0x69, 0x61, 0x73, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
||||||
|
0x10, 0x00, 0x00, 0x00, 0x92, 0xfd, 0xff, 0xff, 0x00, 0x00, 0x00, 0x09,
|
||||||
|
0x6c, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00,
|
||||||
|
0x04, 0x00, 0x00, 0x00, 0x94, 0xfe, 0xff, 0xff, 0x14, 0x00, 0x00, 0x00,
|
||||||
|
0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xe8, 0x76, 0x51, 0x3c,
|
||||||
|
0x34, 0x00, 0x00, 0x00, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x74, 0x69,
|
||||||
|
0x61, 0x6c, 0x5f, 0x31, 0x2f, 0x64, 0x65, 0x6e, 0x73, 0x65, 0x5f, 0x33,
|
||||||
|
0x2f, 0x4d, 0x61, 0x74, 0x4d, 0x75, 0x6c, 0x2f, 0x52, 0x65, 0x61, 0x64,
|
||||||
|
0x56, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x4f, 0x70, 0x2f, 0x74,
|
||||||
|
0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x73, 0x65, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x02, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
|
||||||
|
0x12, 0xfe, 0xff, 0xff, 0x00, 0x00, 0x00, 0x09, 0x6c, 0x00, 0x00, 0x00,
|
||||||
|
0x07, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
|
||||||
|
0x04, 0xfe, 0xff, 0xff, 0x30, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00,
|
||||||
|
0x18, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
||||||
|
0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x01, 0x00, 0x00, 0x00, 0xd2, 0x91, 0x43, 0x3c, 0x01, 0x00, 0x00, 0x00,
|
||||||
|
0x40, 0xce, 0x42, 0x40, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x19, 0x00, 0x00, 0x00, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x74, 0x69,
|
||||||
|
0x61, 0x6c, 0x5f, 0x31, 0x2f, 0x64, 0x65, 0x6e, 0x73, 0x65, 0x5f, 0x32,
|
||||||
|
0x2f, 0x52, 0x65, 0x6c, 0x75, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
|
||||||
|
0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x92, 0xfe, 0xff, 0xff,
|
||||||
|
0x00, 0x00, 0x00, 0x02, 0x5c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
|
||||||
|
0x2c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x94, 0xff, 0xff, 0xff,
|
||||||
|
0x18, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x01, 0x00, 0x00, 0x00, 0x28, 0xb3, 0xd9, 0x38, 0x20, 0x00, 0x00, 0x00,
|
||||||
|
0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x5f, 0x31,
|
||||||
|
0x2f, 0x64, 0x65, 0x6e, 0x73, 0x65, 0x5f, 0x32, 0x2f, 0x4d, 0x61, 0x74,
|
||||||
|
0x4d, 0x75, 0x6c, 0x5f, 0x62, 0x69, 0x61, 0x73, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0xfe, 0xfe, 0xff, 0xff,
|
||||||
|
0x00, 0x00, 0x00, 0x09, 0x78, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
|
||||||
|
0x34, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x0c, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x08, 0x00, 0x0c, 0x00, 0x00, 0x00,
|
||||||
|
0x14, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
||||||
|
0xd5, 0x6b, 0x8a, 0x3b, 0x34, 0x00, 0x00, 0x00, 0x73, 0x65, 0x71, 0x75,
|
||||||
|
0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x5f, 0x31, 0x2f, 0x64, 0x65, 0x6e,
|
||||||
|
0x73, 0x65, 0x5f, 0x32, 0x2f, 0x4d, 0x61, 0x74, 0x4d, 0x75, 0x6c, 0x2f,
|
||||||
|
0x52, 0x65, 0x61, 0x64, 0x56, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65,
|
||||||
|
0x4f, 0x70, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x73, 0x65,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
|
||||||
|
0x01, 0x00, 0x00, 0x00, 0x8a, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x09,
|
||||||
|
0x60, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00,
|
||||||
|
0x04, 0x00, 0x00, 0x00, 0x7c, 0xff, 0xff, 0xff, 0x2c, 0x00, 0x00, 0x00,
|
||||||
|
0x20, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
|
||||||
|
0x01, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||||
|
0x01, 0x00, 0x00, 0x00, 0x5d, 0x4f, 0xc9, 0x3c, 0x01, 0x00, 0x00, 0x00,
|
||||||
|
0x0e, 0x86, 0xc8, 0x40, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x12, 0x00, 0x00, 0x00, 0x64, 0x65, 0x6e, 0x73, 0x65, 0x5f, 0x32, 0x5f,
|
||||||
|
0x69, 0x6e, 0x70, 0x75, 0x74, 0x5f, 0x69, 0x6e, 0x74, 0x38, 0x00, 0x00,
|
||||||
|
0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x0e, 0x00, 0x18, 0x00, 0x08, 0x00, 0x07, 0x00, 0x0c, 0x00,
|
||||||
|
0x10, 0x00, 0x14, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09,
|
||||||
|
0x6c, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00,
|
||||||
|
0x10, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x14, 0x00, 0x04, 0x00, 0x08, 0x00,
|
||||||
|
0x0c, 0x00, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00,
|
||||||
|
0x24, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
|
||||||
|
0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x1a, 0xde, 0x0a, 0x3c,
|
||||||
|
0x01, 0x00, 0x00, 0x00, 0x66, 0x64, 0x87, 0x3f, 0x01, 0x00, 0x00, 0x00,
|
||||||
|
0x13, 0x42, 0x8d, 0xbf, 0x0d, 0x00, 0x00, 0x00, 0x49, 0x64, 0x65, 0x6e,
|
||||||
|
0x74, 0x69, 0x74, 0x79, 0x5f, 0x69, 0x6e, 0x74, 0x38, 0x00, 0x00, 0x00,
|
||||||
|
0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
||||||
|
0x03, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00,
|
||||||
|
0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x0e, 0x00, 0x07, 0x00,
|
||||||
|
0x00, 0x00, 0x08, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06,
|
||||||
|
0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x06, 0x00, 0x05, 0x00,
|
||||||
|
0x06, 0x00, 0x00, 0x00, 0x00, 0x72, 0x0a, 0x00, 0x0c, 0x00, 0x07, 0x00,
|
||||||
|
0x00, 0x00, 0x08, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09,
|
||||||
|
0x04, 0x00, 0x00, 0x00};
|
||||||
|
const int g_model_len = 2512;
|
|
@ -1,4 +1,4 @@
|
||||||
/* Copyright 2019 The TensorFlow Authors. All Rights Reserved.
|
/* Copyright 2020 The TensorFlow Authors. All Rights Reserved.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
@ -13,15 +13,19 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
==============================================================================*/
|
==============================================================================*/
|
||||||
|
|
||||||
|
// Automatically created from a TensorFlow Lite flatbuffer using the command:
|
||||||
|
// xxd -i model.tflite > model.cc
|
||||||
|
|
||||||
// This is a standard TensorFlow Lite model file that has been converted into a
|
// This is a standard TensorFlow Lite model file that has been converted into a
|
||||||
// C data array, so it can be easily compiled into a binary for devices that
|
// C data array, so it can be easily compiled into a binary for devices that
|
||||||
// don't have a file system. It was created using the command:
|
// don't have a file system.
|
||||||
// xxd -i sine_model.tflite > sine_model_data.cc
|
|
||||||
|
|
||||||
#ifndef TENSORFLOW_LITE_MICRO_EXAMPLES_HELLO_WORLD_SINE_MODEL_DATA_H_
|
// See train/README.md for a full description of the creation process.
|
||||||
#define TENSORFLOW_LITE_MICRO_EXAMPLES_HELLO_WORLD_SINE_MODEL_DATA_H_
|
|
||||||
|
|
||||||
extern const unsigned char g_sine_model_data[];
|
#ifndef TENSORFLOW_LITE_MICRO_EXAMPLES_HELLO_WORLD_MODEL_H_
|
||||||
extern const int g_sine_model_data_len;
|
#define TENSORFLOW_LITE_MICRO_EXAMPLES_HELLO_WORLD_MODEL_H_
|
||||||
|
|
||||||
#endif // TENSORFLOW_LITE_MICRO_EXAMPLES_HELLO_WORLD_SINE_MODEL_DATA_H_
|
extern const unsigned char g_model[];
|
||||||
|
extern const int g_model_len;
|
||||||
|
|
||||||
|
#endif // TENSORFLOW_LITE_MICRO_EXAMPLES_HELLO_WORLD_MODEL_H_
|
|
@ -1,255 +0,0 @@
|
||||||
/* Copyright 2019 The TensorFlow Authors. All Rights Reserved.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
==============================================================================*/
|
|
||||||
|
|
||||||
// Automatically created from a TensorFlow Lite flatbuffer using the command:
|
|
||||||
// xxd -i sine_model.tflite > sine_model_data.cc
|
|
||||||
// See the README for a full description of the creation process.
|
|
||||||
|
|
||||||
#include "tensorflow/lite/micro/examples/hello_world/sine_model_data.h"
|
|
||||||
|
|
||||||
// We need to keep the data array aligned on some architectures.
|
|
||||||
#ifdef __has_attribute
|
|
||||||
#define HAVE_ATTRIBUTE(x) __has_attribute(x)
|
|
||||||
#else
|
|
||||||
#define HAVE_ATTRIBUTE(x) 0
|
|
||||||
#endif
|
|
||||||
#if HAVE_ATTRIBUTE(aligned) || (defined(__GNUC__) && !defined(__clang__))
|
|
||||||
#define DATA_ALIGN_ATTRIBUTE __attribute__((aligned(4)))
|
|
||||||
#else
|
|
||||||
#define DATA_ALIGN_ATTRIBUTE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
const unsigned char g_sine_model_data[] DATA_ALIGN_ATTRIBUTE = {
|
|
||||||
0x18, 0x00, 0x00, 0x00, 0x54, 0x46, 0x4c, 0x33, 0x00, 0x00, 0x0e, 0x00,
|
|
||||||
0x18, 0x00, 0x04, 0x00, 0x08, 0x00, 0x0c, 0x00, 0x10, 0x00, 0x14, 0x00,
|
|
||||||
0x0e, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, 0x0a, 0x00, 0x00,
|
|
||||||
0xb8, 0x05, 0x00, 0x00, 0xa0, 0x05, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
|
|
||||||
0x0b, 0x00, 0x00, 0x00, 0x90, 0x05, 0x00, 0x00, 0x7c, 0x05, 0x00, 0x00,
|
|
||||||
0x24, 0x05, 0x00, 0x00, 0xd4, 0x04, 0x00, 0x00, 0xc4, 0x00, 0x00, 0x00,
|
|
||||||
0x74, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00,
|
|
||||||
0x14, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
|
|
||||||
0x54, 0xf6, 0xff, 0xff, 0x58, 0xf6, 0xff, 0xff, 0x5c, 0xf6, 0xff, 0xff,
|
|
||||||
0x60, 0xf6, 0xff, 0xff, 0xc2, 0xfa, 0xff, 0xff, 0x04, 0x00, 0x00, 0x00,
|
|
||||||
0x40, 0x00, 0x00, 0x00, 0x7c, 0x19, 0xa7, 0x3e, 0x99, 0x81, 0xb9, 0x3e,
|
|
||||||
0x56, 0x8b, 0x9f, 0x3e, 0x88, 0xd8, 0x12, 0xbf, 0x74, 0x10, 0x56, 0x3e,
|
|
||||||
0xfe, 0xc6, 0xdf, 0xbe, 0xf2, 0x10, 0x5a, 0xbe, 0xf0, 0xe2, 0x0a, 0xbe,
|
|
||||||
0x10, 0x5a, 0x98, 0xbe, 0xb9, 0x36, 0xce, 0x3d, 0x8f, 0x7f, 0x87, 0x3e,
|
|
||||||
0x2c, 0xb1, 0xfd, 0xbd, 0xe6, 0xa6, 0x8a, 0xbe, 0xa5, 0x3e, 0xda, 0x3e,
|
|
||||||
0x50, 0x34, 0xed, 0xbd, 0x90, 0x91, 0x69, 0xbe, 0x0e, 0xfb, 0xff, 0xff,
|
|
||||||
0x04, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x67, 0x41, 0x48, 0xbf,
|
|
||||||
0x24, 0xcd, 0xa0, 0xbe, 0xb7, 0x92, 0x0c, 0xbf, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x98, 0xfe, 0x3c, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4a, 0x17, 0x9a, 0xbe,
|
|
||||||
0x41, 0xcb, 0xb6, 0xbe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x13, 0xd6, 0x1e, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x5a, 0xfb, 0xff, 0xff, 0x04, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00,
|
|
||||||
0x4b, 0x98, 0xdd, 0xbd, 0x40, 0x6b, 0xcb, 0xbe, 0x36, 0x0c, 0xd4, 0x3c,
|
|
||||||
0xbd, 0x44, 0xb5, 0x3e, 0x95, 0x70, 0xe3, 0x3e, 0xe7, 0xac, 0x86, 0x3e,
|
|
||||||
0x00, 0xc4, 0x4e, 0x3d, 0x7e, 0xa6, 0x1d, 0x3e, 0xbd, 0x87, 0xbb, 0x3e,
|
|
||||||
0xb4, 0xb8, 0x09, 0xbf, 0xa1, 0x1f, 0xf8, 0xbe, 0x8d, 0x90, 0xdd, 0x3e,
|
|
||||||
0xde, 0xfa, 0x6f, 0xbe, 0xb2, 0x75, 0xe4, 0x3d, 0x6e, 0xfe, 0x36, 0x3e,
|
|
||||||
0x20, 0x18, 0xc2, 0xbe, 0x39, 0xc7, 0xfb, 0xbe, 0xfe, 0xa4, 0x30, 0xbe,
|
|
||||||
0xf7, 0x91, 0xde, 0xbe, 0xde, 0xab, 0x24, 0x3e, 0xfb, 0xbb, 0xce, 0x3e,
|
|
||||||
0xeb, 0x23, 0x80, 0xbe, 0x7b, 0x58, 0x73, 0xbe, 0x9a, 0x2e, 0x03, 0x3e,
|
|
||||||
0x10, 0x42, 0xa9, 0xbc, 0x10, 0x12, 0x64, 0xbd, 0xe3, 0x8d, 0x0c, 0x3d,
|
|
||||||
0x9e, 0x48, 0x97, 0xbe, 0x34, 0x51, 0xd4, 0xbe, 0x02, 0x3b, 0x0d, 0x3e,
|
|
||||||
0x62, 0x67, 0x89, 0xbe, 0x74, 0xdf, 0xa2, 0x3d, 0xf3, 0x25, 0xb3, 0xbe,
|
|
||||||
0xef, 0x34, 0x7b, 0x3d, 0x61, 0x70, 0xe3, 0x3d, 0xba, 0x76, 0xc0, 0xbe,
|
|
||||||
0x7d, 0xe9, 0xa7, 0x3e, 0xc3, 0xab, 0xd0, 0xbe, 0xcf, 0x7c, 0xdb, 0xbe,
|
|
||||||
0x70, 0x27, 0x9a, 0xbe, 0x98, 0xf5, 0x3c, 0xbd, 0xff, 0x4b, 0x4b, 0x3e,
|
|
||||||
0x7e, 0xa0, 0xf8, 0xbd, 0xd4, 0x6e, 0x86, 0x3d, 0x00, 0x4a, 0x07, 0x3a,
|
|
||||||
0x4c, 0x24, 0x61, 0xbe, 0x54, 0x68, 0xf7, 0xbd, 0x02, 0x3f, 0x77, 0xbe,
|
|
||||||
0x23, 0x79, 0xb3, 0x3e, 0x1c, 0x83, 0xad, 0xbd, 0xc8, 0x92, 0x8d, 0x3e,
|
|
||||||
0xa8, 0xf3, 0x15, 0xbd, 0xe6, 0x4d, 0x6c, 0x3d, 0xac, 0xe7, 0x98, 0xbe,
|
|
||||||
0x81, 0xec, 0xbd, 0x3e, 0xe2, 0x55, 0x73, 0x3e, 0xc1, 0x77, 0xc7, 0x3e,
|
|
||||||
0x6e, 0x1b, 0x5e, 0x3d, 0x27, 0x78, 0x02, 0x3f, 0xd4, 0x21, 0x90, 0x3d,
|
|
||||||
0x52, 0xdc, 0x1f, 0x3e, 0xbf, 0xda, 0x88, 0x3e, 0x80, 0x79, 0xe3, 0xbd,
|
|
||||||
0x40, 0x6f, 0x10, 0xbe, 0x20, 0x43, 0x2e, 0xbd, 0xf0, 0x76, 0xc5, 0xbd,
|
|
||||||
0xcc, 0xa0, 0x04, 0xbe, 0xf0, 0x69, 0xd7, 0xbe, 0xb1, 0xfe, 0x64, 0xbe,
|
|
||||||
0x20, 0x41, 0x84, 0xbe, 0xb2, 0xc3, 0x26, 0xbe, 0xd8, 0xf4, 0x09, 0xbe,
|
|
||||||
0x64, 0x44, 0xd1, 0x3d, 0xd5, 0xe1, 0xc8, 0xbe, 0x35, 0xbc, 0x3f, 0xbe,
|
|
||||||
0xc0, 0x94, 0x82, 0x3d, 0xdc, 0x2b, 0xb1, 0xbd, 0x02, 0xdb, 0xbf, 0xbe,
|
|
||||||
0xa5, 0x7f, 0x8a, 0x3e, 0x21, 0xb4, 0xa2, 0x3e, 0xcd, 0x86, 0x56, 0xbf,
|
|
||||||
0x9c, 0x3b, 0x76, 0xbc, 0x85, 0x6d, 0x60, 0xbf, 0x86, 0x00, 0x3c, 0xbe,
|
|
||||||
0xc1, 0x23, 0x7e, 0x3e, 0x96, 0xcd, 0x3f, 0x3e, 0x86, 0x91, 0x2d, 0x3e,
|
|
||||||
0x55, 0xef, 0x87, 0x3e, 0x7e, 0x97, 0x03, 0xbe, 0x2a, 0xcd, 0x01, 0x3e,
|
|
||||||
0x32, 0xc9, 0x8e, 0xbe, 0x72, 0x77, 0x3b, 0xbe, 0xe0, 0xa1, 0xbc, 0xbe,
|
|
||||||
0x8d, 0xb7, 0xa7, 0x3e, 0x1c, 0x05, 0x95, 0xbe, 0xf7, 0x1f, 0xbb, 0x3e,
|
|
||||||
0xc9, 0x3e, 0xd6, 0x3e, 0x80, 0x42, 0xe9, 0xbd, 0x27, 0x0c, 0xd2, 0xbe,
|
|
||||||
0x5c, 0x32, 0x34, 0xbe, 0x14, 0xcb, 0xca, 0xbd, 0xdd, 0x3a, 0x67, 0xbe,
|
|
||||||
0x1c, 0xbb, 0x8d, 0xbe, 0x91, 0xac, 0x5c, 0xbe, 0x52, 0x40, 0x6f, 0xbe,
|
|
||||||
0xd7, 0x71, 0x94, 0x3e, 0x18, 0x71, 0x09, 0xbe, 0x9b, 0x29, 0xd9, 0xbe,
|
|
||||||
0x7d, 0x66, 0xd2, 0xbe, 0x98, 0xd6, 0xb2, 0xbe, 0x00, 0xc9, 0x84, 0x3a,
|
|
||||||
0xbc, 0xda, 0xc2, 0xbd, 0x1d, 0xc2, 0x1b, 0xbf, 0xd4, 0xdd, 0x92, 0x3e,
|
|
||||||
0x07, 0x87, 0x6c, 0xbe, 0x40, 0xc2, 0x3b, 0xbe, 0xbd, 0xe2, 0x9c, 0x3e,
|
|
||||||
0x0a, 0xb5, 0xa0, 0xbe, 0xe2, 0xd5, 0x9c, 0xbe, 0x3e, 0xbb, 0x7c, 0x3e,
|
|
||||||
0x17, 0xb4, 0xcf, 0x3e, 0xd5, 0x8e, 0xc8, 0xbe, 0x7c, 0xf9, 0x5c, 0x3e,
|
|
||||||
0x80, 0xfc, 0x0d, 0x3d, 0xc5, 0xd5, 0x8b, 0x3e, 0xf5, 0x17, 0xa2, 0x3e,
|
|
||||||
0xc7, 0x60, 0x89, 0xbe, 0xec, 0x95, 0x87, 0x3d, 0x7a, 0xc2, 0x5d, 0xbf,
|
|
||||||
0x77, 0x94, 0x98, 0x3e, 0x77, 0x39, 0x07, 0xbc, 0x42, 0x29, 0x00, 0x3e,
|
|
||||||
0xaf, 0xd0, 0xa9, 0x3e, 0x31, 0x23, 0xc4, 0xbe, 0x95, 0x36, 0x5b, 0xbe,
|
|
||||||
0xc7, 0xdc, 0x83, 0xbe, 0x1e, 0x6b, 0x47, 0x3e, 0x5b, 0x24, 0x99, 0x3e,
|
|
||||||
0x99, 0x27, 0x54, 0x3e, 0xc8, 0x20, 0xdd, 0xbd, 0x5a, 0x86, 0x2f, 0x3e,
|
|
||||||
0x80, 0xf0, 0x69, 0xbe, 0x44, 0xfc, 0x84, 0xbd, 0x82, 0xa0, 0x2a, 0xbe,
|
|
||||||
0x87, 0xe6, 0x2a, 0x3e, 0xd8, 0x34, 0xae, 0x3d, 0x50, 0xbd, 0xb5, 0x3e,
|
|
||||||
0xc4, 0x8c, 0x88, 0xbe, 0xe3, 0xbc, 0xa5, 0x3e, 0xa9, 0xda, 0x9e, 0x3e,
|
|
||||||
0x3e, 0xb8, 0x23, 0xbe, 0x80, 0x90, 0x15, 0x3d, 0x97, 0x3f, 0xc3, 0x3e,
|
|
||||||
0xca, 0x5c, 0x9d, 0x3e, 0x21, 0xe8, 0xe1, 0x3e, 0xc0, 0x49, 0x01, 0xbc,
|
|
||||||
0x00, 0x0b, 0x88, 0xbd, 0x3f, 0xf7, 0xca, 0x3c, 0xfb, 0x5a, 0xb1, 0x3e,
|
|
||||||
0x60, 0xd2, 0x0d, 0x3c, 0xce, 0x23, 0x78, 0xbf, 0x8f, 0x4f, 0xb9, 0xbe,
|
|
||||||
0x69, 0x6a, 0x34, 0xbf, 0x4b, 0x5e, 0xa9, 0x3e, 0x64, 0x8c, 0xd9, 0x3e,
|
|
||||||
0x52, 0x77, 0x36, 0x3e, 0xeb, 0xaf, 0xbe, 0x3e, 0x40, 0xbe, 0x36, 0x3c,
|
|
||||||
0x08, 0x65, 0x3b, 0xbd, 0x55, 0xe0, 0x66, 0xbd, 0xd2, 0xe8, 0x9b, 0xbe,
|
|
||||||
0x86, 0xe3, 0x09, 0xbe, 0x93, 0x3d, 0xdd, 0x3e, 0x0f, 0x66, 0x18, 0x3f,
|
|
||||||
0x18, 0x05, 0x33, 0xbd, 0xde, 0x15, 0xd7, 0xbe, 0xaa, 0xcf, 0x49, 0xbe,
|
|
||||||
0xa2, 0xa5, 0x64, 0x3e, 0xe6, 0x9c, 0x42, 0xbe, 0x54, 0x42, 0xcc, 0x3d,
|
|
||||||
0xa0, 0xbd, 0x9d, 0xbe, 0xc2, 0x69, 0x48, 0x3e, 0x5b, 0x8b, 0xa2, 0xbe,
|
|
||||||
0xc0, 0x13, 0x87, 0x3d, 0x36, 0xfd, 0x69, 0x3e, 0x05, 0x86, 0x40, 0xbe,
|
|
||||||
0x1e, 0x7a, 0xce, 0xbe, 0x46, 0x13, 0xa7, 0xbe, 0x68, 0x52, 0x86, 0xbe,
|
|
||||||
0x04, 0x9e, 0x86, 0xbd, 0x8c, 0x54, 0xc1, 0x3d, 0xe0, 0x3b, 0xad, 0x3c,
|
|
||||||
0x42, 0x67, 0x85, 0xbd, 0xea, 0x97, 0x42, 0x3e, 0x6e, 0x13, 0x3b, 0xbf,
|
|
||||||
0x56, 0x5b, 0x16, 0x3e, 0xaa, 0xab, 0xdf, 0x3e, 0xc8, 0x41, 0x36, 0x3d,
|
|
||||||
0x24, 0x2d, 0x47, 0xbe, 0x77, 0xa5, 0xae, 0x3e, 0xc0, 0xc2, 0x5b, 0x3c,
|
|
||||||
0xac, 0xac, 0x4e, 0x3e, 0x99, 0xec, 0x13, 0xbe, 0xf2, 0xab, 0x73, 0x3e,
|
|
||||||
0xaa, 0xa1, 0x48, 0xbe, 0xe8, 0xd3, 0x01, 0xbe, 0x60, 0xb7, 0xc7, 0xbd,
|
|
||||||
0x64, 0x72, 0xd3, 0x3d, 0x83, 0xd3, 0x99, 0x3e, 0x0c, 0x76, 0x34, 0xbe,
|
|
||||||
0x42, 0xda, 0x0d, 0x3e, 0xfb, 0x47, 0x9a, 0x3e, 0x8b, 0xdc, 0x92, 0xbe,
|
|
||||||
0x56, 0x7f, 0x6b, 0x3e, 0x04, 0xd4, 0x88, 0xbd, 0x11, 0x9e, 0x80, 0x3e,
|
|
||||||
0x3c, 0x89, 0xff, 0x3d, 0xb3, 0x3e, 0x88, 0x3e, 0xf7, 0xf0, 0x88, 0x3e,
|
|
||||||
0x28, 0xfb, 0xc9, 0xbe, 0x53, 0x3e, 0xcf, 0x3e, 0xac, 0x75, 0xdc, 0xbe,
|
|
||||||
0xdd, 0xca, 0xd7, 0x3e, 0x01, 0x58, 0xa7, 0x3e, 0x29, 0xb8, 0x13, 0xbf,
|
|
||||||
0x76, 0x81, 0x12, 0xbc, 0x28, 0x8b, 0x16, 0xbf, 0x0e, 0xec, 0x0e, 0x3e,
|
|
||||||
0x40, 0x0a, 0xdb, 0xbd, 0x98, 0xec, 0xbf, 0xbd, 0x32, 0x55, 0x0c, 0xbe,
|
|
||||||
0xfb, 0xf9, 0xc9, 0x3e, 0x83, 0x4a, 0x6d, 0xbe, 0x76, 0x59, 0xe2, 0xbe,
|
|
||||||
0x54, 0x7d, 0x9f, 0xbb, 0x9d, 0xe8, 0x95, 0x3e, 0x5c, 0xd3, 0xd0, 0x3d,
|
|
||||||
0x19, 0x8a, 0xb0, 0x3e, 0xde, 0x6f, 0x2e, 0xbe, 0xd0, 0x16, 0x83, 0x3d,
|
|
||||||
0x9c, 0x7d, 0x11, 0xbf, 0x2b, 0xcc, 0x25, 0x3c, 0x2a, 0xa5, 0x27, 0xbe,
|
|
||||||
0x22, 0x14, 0xc7, 0xbe, 0x5e, 0x7a, 0xac, 0x3e, 0x4e, 0x41, 0x94, 0xbe,
|
|
||||||
0x5a, 0x68, 0x7b, 0x3e, 0x86, 0xfd, 0x4e, 0x3e, 0xa2, 0x56, 0x6a, 0xbe,
|
|
||||||
0xca, 0xfe, 0x81, 0xbe, 0x43, 0xc3, 0xb1, 0xbd, 0xc5, 0xb8, 0xa7, 0x3e,
|
|
||||||
0x55, 0x23, 0xcd, 0x3e, 0xaf, 0x2e, 0x76, 0x3e, 0x69, 0xa8, 0x90, 0xbe,
|
|
||||||
0x0d, 0xba, 0xb9, 0x3e, 0x66, 0xff, 0xff, 0xff, 0x04, 0x00, 0x00, 0x00,
|
|
||||||
0x40, 0x00, 0x00, 0x00, 0x53, 0xd6, 0xe2, 0x3d, 0x66, 0xb6, 0xcc, 0x3e,
|
|
||||||
0x03, 0xe7, 0xf6, 0x3e, 0xe0, 0x28, 0x10, 0xbf, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x3e, 0x3d, 0xb0, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x62, 0xf0, 0x77, 0x3e,
|
|
||||||
0xa6, 0x9d, 0xa4, 0x3e, 0x3a, 0x4b, 0xf3, 0xbe, 0x71, 0x9e, 0xa7, 0x3e,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x34, 0x39, 0xa2, 0x3e, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0xcc, 0x9c, 0x4a, 0x3e, 0xab, 0x40, 0xa3, 0x3e, 0xb2, 0xff, 0xff, 0xff,
|
|
||||||
0x04, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0xb3, 0x71, 0x67, 0x3f,
|
|
||||||
0x9a, 0x7a, 0x95, 0xbf, 0xe1, 0x48, 0xe8, 0xbe, 0x8a, 0x72, 0x96, 0x3e,
|
|
||||||
0x00, 0xd2, 0xd3, 0xbb, 0x1a, 0xc5, 0xd7, 0x3f, 0xac, 0x7e, 0xc8, 0xbe,
|
|
||||||
0x90, 0xa7, 0x95, 0xbe, 0x3b, 0xd7, 0xdc, 0xbe, 0x41, 0xa8, 0x16, 0x3f,
|
|
||||||
0x50, 0x5b, 0xcb, 0x3f, 0x52, 0xb9, 0xed, 0xbe, 0x2e, 0xa7, 0xc6, 0xbe,
|
|
||||||
0xaf, 0x0f, 0x14, 0xbf, 0xb3, 0xda, 0x59, 0x3f, 0x02, 0xec, 0xd7, 0xbe,
|
|
||||||
0x00, 0x00, 0x06, 0x00, 0x08, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00,
|
|
||||||
0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x66, 0x11, 0x1f, 0xbf,
|
|
||||||
0xb8, 0xfb, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x54, 0x4f, 0x43, 0x4f,
|
|
||||||
0x20, 0x43, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x74, 0x65, 0x64, 0x2e, 0x00,
|
|
||||||
0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x14, 0x00,
|
|
||||||
0x04, 0x00, 0x08, 0x00, 0x0c, 0x00, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00,
|
|
||||||
0xf0, 0x00, 0x00, 0x00, 0xe4, 0x00, 0x00, 0x00, 0xd8, 0x00, 0x00, 0x00,
|
|
||||||
0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x90, 0x00, 0x00, 0x00,
|
|
||||||
0x48, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0xce, 0xff, 0xff, 0xff,
|
|
||||||
0x00, 0x00, 0x00, 0x08, 0x18, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
|
|
||||||
0x04, 0x00, 0x00, 0x00, 0x1c, 0xfc, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
|
|
||||||
0x08, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00,
|
|
||||||
0x14, 0x00, 0x00, 0x00, 0x08, 0x00, 0x0c, 0x00, 0x07, 0x00, 0x10, 0x00,
|
|
||||||
0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x1c, 0x00, 0x00, 0x00,
|
|
||||||
0x10, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0xba, 0xff, 0xff, 0xff,
|
|
||||||
0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
|
|
||||||
0x03, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
|
|
||||||
0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x16, 0x00, 0x00, 0x00,
|
|
||||||
0x08, 0x00, 0x0c, 0x00, 0x07, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x08, 0x24, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00,
|
|
||||||
0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x08, 0x00, 0x07, 0x00,
|
|
||||||
0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00,
|
|
||||||
0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
|
||||||
0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
|
||||||
0x0a, 0x00, 0x00, 0x00, 0x10, 0x03, 0x00, 0x00, 0xa4, 0x02, 0x00, 0x00,
|
|
||||||
0x40, 0x02, 0x00, 0x00, 0xf4, 0x01, 0x00, 0x00, 0xac, 0x01, 0x00, 0x00,
|
|
||||||
0x48, 0x01, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0xb4, 0x00, 0x00, 0x00,
|
|
||||||
0x50, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x26, 0xfd, 0xff, 0xff,
|
|
||||||
0x3c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
|
|
||||||
0x04, 0x00, 0x00, 0x00, 0x18, 0xfd, 0xff, 0xff, 0x20, 0x00, 0x00, 0x00,
|
|
||||||
0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x5f, 0x31,
|
|
||||||
0x2f, 0x64, 0x65, 0x6e, 0x73, 0x65, 0x5f, 0x34, 0x2f, 0x4d, 0x61, 0x74,
|
|
||||||
0x4d, 0x75, 0x6c, 0x5f, 0x62, 0x69, 0x61, 0x73, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x6e, 0xfd, 0xff, 0xff,
|
|
||||||
0x50, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
|
|
||||||
0x04, 0x00, 0x00, 0x00, 0x60, 0xfd, 0xff, 0xff, 0x34, 0x00, 0x00, 0x00,
|
|
||||||
0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x5f, 0x31,
|
|
||||||
0x2f, 0x64, 0x65, 0x6e, 0x73, 0x65, 0x5f, 0x34, 0x2f, 0x4d, 0x61, 0x74,
|
|
||||||
0x4d, 0x75, 0x6c, 0x2f, 0x52, 0x65, 0x61, 0x64, 0x56, 0x61, 0x72, 0x69,
|
|
||||||
0x61, 0x62, 0x6c, 0x65, 0x4f, 0x70, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73,
|
|
||||||
0x70, 0x6f, 0x73, 0x65, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
|
|
||||||
0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0xce, 0xfd, 0xff, 0xff,
|
|
||||||
0x34, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
|
|
||||||
0x04, 0x00, 0x00, 0x00, 0xc0, 0xfd, 0xff, 0xff, 0x19, 0x00, 0x00, 0x00,
|
|
||||||
0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x5f, 0x31,
|
|
||||||
0x2f, 0x64, 0x65, 0x6e, 0x73, 0x65, 0x5f, 0x33, 0x2f, 0x52, 0x65, 0x6c,
|
|
||||||
0x75, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
|
||||||
0x10, 0x00, 0x00, 0x00, 0x12, 0xfe, 0xff, 0xff, 0x3c, 0x00, 0x00, 0x00,
|
|
||||||
0x03, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
|
|
||||||
0x04, 0xfe, 0xff, 0xff, 0x20, 0x00, 0x00, 0x00, 0x73, 0x65, 0x71, 0x75,
|
|
||||||
0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x5f, 0x31, 0x2f, 0x64, 0x65, 0x6e,
|
|
||||||
0x73, 0x65, 0x5f, 0x33, 0x2f, 0x4d, 0x61, 0x74, 0x4d, 0x75, 0x6c, 0x5f,
|
|
||||||
0x62, 0x69, 0x61, 0x73, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
|
||||||
0x10, 0x00, 0x00, 0x00, 0x5a, 0xfe, 0xff, 0xff, 0x50, 0x00, 0x00, 0x00,
|
|
||||||
0x04, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
|
|
||||||
0x4c, 0xfe, 0xff, 0xff, 0x34, 0x00, 0x00, 0x00, 0x73, 0x65, 0x71, 0x75,
|
|
||||||
0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x5f, 0x31, 0x2f, 0x64, 0x65, 0x6e,
|
|
||||||
0x73, 0x65, 0x5f, 0x33, 0x2f, 0x4d, 0x61, 0x74, 0x4d, 0x75, 0x6c, 0x2f,
|
|
||||||
0x52, 0x65, 0x61, 0x64, 0x56, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65,
|
|
||||||
0x4f, 0x70, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x73, 0x65,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
|
|
||||||
0x10, 0x00, 0x00, 0x00, 0xba, 0xfe, 0xff, 0xff, 0x34, 0x00, 0x00, 0x00,
|
|
||||||
0x0a, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
|
|
||||||
0xac, 0xfe, 0xff, 0xff, 0x19, 0x00, 0x00, 0x00, 0x73, 0x65, 0x71, 0x75,
|
|
||||||
0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x5f, 0x31, 0x2f, 0x64, 0x65, 0x6e,
|
|
||||||
0x73, 0x65, 0x5f, 0x32, 0x2f, 0x52, 0x65, 0x6c, 0x75, 0x00, 0x00, 0x00,
|
|
||||||
0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
|
|
||||||
0xfe, 0xfe, 0xff, 0xff, 0x3c, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
|
|
||||||
0x0c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0xf0, 0xfe, 0xff, 0xff,
|
|
||||||
0x20, 0x00, 0x00, 0x00, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x74, 0x69,
|
|
||||||
0x61, 0x6c, 0x5f, 0x31, 0x2f, 0x64, 0x65, 0x6e, 0x73, 0x65, 0x5f, 0x32,
|
|
||||||
0x2f, 0x4d, 0x61, 0x74, 0x4d, 0x75, 0x6c, 0x5f, 0x62, 0x69, 0x61, 0x73,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
|
|
||||||
0x46, 0xff, 0xff, 0xff, 0x50, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
|
|
||||||
0x0c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x38, 0xff, 0xff, 0xff,
|
|
||||||
0x34, 0x00, 0x00, 0x00, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x74, 0x69,
|
|
||||||
0x61, 0x6c, 0x5f, 0x31, 0x2f, 0x64, 0x65, 0x6e, 0x73, 0x65, 0x5f, 0x32,
|
|
||||||
0x2f, 0x4d, 0x61, 0x74, 0x4d, 0x75, 0x6c, 0x2f, 0x52, 0x65, 0x61, 0x64,
|
|
||||||
0x56, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x4f, 0x70, 0x2f, 0x74,
|
|
||||||
0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x73, 0x65, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x02, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
|
||||||
0xa6, 0xff, 0xff, 0xff, 0x48, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00,
|
|
||||||
0x2c, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x08, 0x00, 0x0c, 0x00,
|
|
||||||
0x04, 0x00, 0x08, 0x00, 0x08, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
|
|
||||||
0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x43,
|
|
||||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00,
|
|
||||||
0x64, 0x65, 0x6e, 0x73, 0x65, 0x5f, 0x32, 0x5f, 0x69, 0x6e, 0x70, 0x75,
|
|
||||||
0x74, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
|
||||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x14, 0x00, 0x04, 0x00,
|
|
||||||
0x00, 0x00, 0x08, 0x00, 0x0c, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00,
|
|
||||||
0x28, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
|
|
||||||
0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00,
|
|
||||||
0x08, 0x00, 0x00, 0x00, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
|
||||||
0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x0a, 0x00, 0x0c, 0x00, 0x07, 0x00, 0x00, 0x00, 0x08, 0x00,
|
|
||||||
0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x03, 0x00, 0x00, 0x00};
|
|
||||||
const int g_sine_model_data_len = 2640;
|
|
|
@ -0,0 +1,69 @@
|
||||||
|
# Hello World Training
|
||||||
|
|
||||||
|
This example shows how to train a 2.5 kB model to generate a `sine` wave.
|
||||||
|
|
||||||
|
## Table of contents
|
||||||
|
|
||||||
|
- [Overview](#overview)
|
||||||
|
- [Training](#training)
|
||||||
|
- [Trained Models](#trained-models)
|
||||||
|
- [Model Architecture](#model-architecture)
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
|
||||||
|
1. Dataset: Data is generated locally in the Jupyter Notebook.
|
||||||
|
2. Dataset Type: **Structured Data**
|
||||||
|
3. Deep Learning Framework: **TensorFlow 2**
|
||||||
|
4. Language: **Python 3.7**
|
||||||
|
5. Model Size: **2.5 kB**
|
||||||
|
6. Model Category: **Regression**
|
||||||
|
|
||||||
|
## Training
|
||||||
|
|
||||||
|
Train the model in the cloud using Google Colaboratory or locally using a
|
||||||
|
Jupyter Notebook.
|
||||||
|
|
||||||
|
<table class="tfo-notebook-buttons" align="left">
|
||||||
|
<td>
|
||||||
|
<a target="_blank" href="https://colab.research.google.com/github/tensorflow/tensorflow/blob/master/tensorflow/lite/micro/examples/hello_world/train/train_hello_world_model.ipynb"><img src="https://www.tensorflow.org/images/colab_logo_32px.png" />Google Colaboratory</a>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<a target="_blank" href="https://github.com/tensorflow/tensorflow/blob/master/tensorflow/lite/micro/examples/hello_world/train/train_hello_world_model.ipynb"><img src="https://www.tensorflow.org/images/GitHub-Mark-32px.png" />Jupyter Notebook</a>
|
||||||
|
</td>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
*Estimated Training Time: 10 minutes.*
|
||||||
|
|
||||||
|
|
||||||
|
## Trained Models
|
||||||
|
|
||||||
|
| Download Link | [hello_world.zip](https://storage.googleapis.com/download.tensorflow.org/models/tflite/micro/hello_world_2020_04_13.zip) |
|
||||||
|
| ------------- |-------------|
|
||||||
|
|
||||||
|
|
||||||
|
The `models` directory in the above zip file can be generated by following the
|
||||||
|
instructions in the [Training](#training) section above. It
|
||||||
|
includes the following 3 model files:
|
||||||
|
|
||||||
|
| Name | Format | Target Framework | Target Device |
|
||||||
|
| :------------- |:-------------|:-------------|-----|
|
||||||
|
| `model.pb` | Keras SavedModel | TensorFlow | Large-Scale/Cloud/Servers |
|
||||||
|
| `model.tflite` *(2.5 kB)* | Fully Quantized* TFLite Model | TensorFlow Lite | Mobile Devices|
|
||||||
|
| `model.cc` | C Source File | TensorFlow Lite for Microcontrollers | Microcontrollers |
|
||||||
|
|
||||||
|
**Fully quantized implies that the model is **strictly int8** quantized
|
||||||
|
**excluding** the input(s) and output(s).*
|
||||||
|
<!-- **Fully quantized implies that the model is **strictly int8** quantized
|
||||||
|
including the input(s)and output(s).* -->
|
||||||
|
|
||||||
|
|
||||||
|
## Model Architecture
|
||||||
|
|
||||||
|
The final model used to simulate a sine wave is displayed below. It is a
|
||||||
|
simple feed forward deep neural network with 2 fully connected layers with
|
||||||
|
ReLu activations and a final fully connected output layer with as shown below.
|
||||||
|
|
||||||
|
![model_architecture.png](../images/model_architecture.png)
|
||||||
|
|
||||||
|
*This image was derived from visualizing the 'model.tflite' file in [Netron](https://github.com/lutzroeder/netron)*
|
||||||
|
|
|
@ -545,4 +545,4 @@ with the model and sample inputs.
|
||||||
|
|
||||||
So far you have used an existing trained model to run inference on
|
So far you have used an existing trained model to run inference on
|
||||||
microcontrollers. If you wish to train your own model, follow the instructions
|
microcontrollers. If you wish to train your own model, follow the instructions
|
||||||
in [train/README.md](train/README.md).
|
given in the [train/](train/) directory.
|
||||||
|
|
|
@ -23,28 +23,48 @@ stop
|
||||||
go
|
go
|
||||||
```
|
```
|
||||||
|
|
||||||
|
The scripts used in training the model have been sourced from the
|
||||||
|
[Simple Audio Recognition](https://www.tensorflow.org/tutorials/sequences/audio_recognition)
|
||||||
|
tutorial.
|
||||||
|
|
||||||
## Table of contents
|
## Table of contents
|
||||||
|
|
||||||
- [Overview](#overview)
|
- [Overview](#overview)
|
||||||
- [Trained Models](#trained-models)
|
|
||||||
- [Training](#training)
|
- [Training](#training)
|
||||||
|
- [Trained Models](#trained-models)
|
||||||
- [Model Architecture](#model-architecture)
|
- [Model Architecture](#model-architecture)
|
||||||
- [Dataset](#dataset)
|
- [Dataset](#dataset)
|
||||||
- [Preprocessing Speech Input](#preprocessing-speech-input)
|
- [Preprocessing Speech Input](#preprocessing-speech-input)
|
||||||
|
- [Other Training Methods](#other-training-methods)
|
||||||
|
|
||||||
## Overview
|
## Overview
|
||||||
|
|
||||||
1. Training Jupyter Notebook: [`train_micro_speech_model.ipynb`](train_micro_speech_model.ipynb)
|
1. Dataset: Speech Commands, Version 2. ([Download Link](https://storage.cloud.google.com/download.tensorflow.org/data/speech_commands_v0.02.tar.gz)
|
||||||
. The training scripts used in this notebook are in the
|
|
||||||
[Simple Audio Recognition](https://www.tensorflow.org/tutorials/sequences/audio_recognition)
|
|
||||||
tutorial.
|
|
||||||
2. Dataset Type: **Speech**
|
|
||||||
3. Dataset: Speech Commands, Version 2. ([Download Link](https://storage.cloud.google.com/download.tensorflow.org/data/speech_commands_v0.02.tar.gz)
|
|
||||||
, [Paper](https://arxiv.org/abs/1804.03209))
|
, [Paper](https://arxiv.org/abs/1804.03209))
|
||||||
4. Deep Learning Framework: **TensorFlow 1.5**
|
2. Dataset Type: **Speech**
|
||||||
5. Language: **Python 3.7**
|
3. Deep Learning Framework: **TensorFlow 1.5**
|
||||||
6. Model Size: **<20 kB**
|
4. Language: **Python 3.7**
|
||||||
7. Model Category: **Multiclass Classification**
|
5. Model Size: **<20 kB**
|
||||||
|
6. Model Category: **Multiclass Classification**
|
||||||
|
|
||||||
|
## Training
|
||||||
|
|
||||||
|
Train the model in the cloud using Google Colaboratory or locally using a
|
||||||
|
Jupyter Notebook.
|
||||||
|
|
||||||
|
<table class="tfo-notebook-buttons" align="left">
|
||||||
|
<td>
|
||||||
|
<a target="_blank" href="https://colab.research.google.com/github/tensorflow/tensorflow/blob/master/tensorflow/lite/micro/examples/micro_speech/train/train_micro_speech_model.ipynb"><img src="https://www.tensorflow.org/images/colab_logo_32px.png" />Google Colaboratory</a>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<a target="_blank" href="https://github.com/tensorflow/tensorflow/blob/master/tensorflow/lite/micro/examples/micro_speech/train/train_micro_speech_model.ipynb"><img src="https://www.tensorflow.org/images/GitHub-Mark-32px.png" />Jupyter Notebook</a>
|
||||||
|
</td>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
*Estimated Training Time: ~2 Hours.*
|
||||||
|
|
||||||
|
For more options, refer to the [Other Training Methods](#other-training-methods)
|
||||||
|
section.
|
||||||
|
|
||||||
## Trained Models
|
## Trained Models
|
||||||
|
|
||||||
|
@ -52,7 +72,7 @@ tutorial.
|
||||||
| ------------- |-------------|
|
| ------------- |-------------|
|
||||||
|
|
||||||
The `models` directory in the above zip file can be generated by following the
|
The `models` directory in the above zip file can be generated by following the
|
||||||
instructions in the [Training](#training) section below. It
|
instructions in the [Training](#training) section above. It
|
||||||
includes the following 3 model files:
|
includes the following 3 model files:
|
||||||
|
|
||||||
| Name | Format | Target Framework | Target Device |
|
| Name | Format | Target Framework | Target Device |
|
||||||
|
@ -61,67 +81,11 @@ includes the following 3 model files:
|
||||||
| `model.tflite` *(<20 kB)* | Fully Quantized* TFLite Model | TensorFlow Lite | Mobile Devices|
|
| `model.tflite` *(<20 kB)* | Fully Quantized* TFLite Model | TensorFlow Lite | Mobile Devices|
|
||||||
| `model.cc` | C Source File | TensorFlow Lite for Microcontrollers | Microcontrollers |
|
| `model.cc` | C Source File | TensorFlow Lite for Microcontrollers | Microcontrollers |
|
||||||
|
|
||||||
*Fully quantized implies that the model is **strictly int8** quantized
|
**Fully quantized implies that the model is **strictly int8** quantized
|
||||||
**including** the input(s) and output(s).*
|
**including** the input(s) and output(s).*
|
||||||
<!-- **Fully quantized implies that the model is **strictly int8** except the
|
<!-- **Fully quantized implies that the model is **strictly int8** except the
|
||||||
input(s) and output(s) which remain float.* -->
|
input(s) and output(s) which remain float.* -->
|
||||||
|
|
||||||
|
|
||||||
## Training
|
|
||||||
|
|
||||||
### 1. Use [Google Colaboratory](https://colab.research.google.com)
|
|
||||||
|
|
||||||
*We strongly recommend trying this approach first.*
|
|
||||||
|
|
||||||
| Run in Google Colaboratory | <a target="_blank" href="https://colab.research.google.com/github/tensorflow/tensorflow/blob/master/tensorflow/lite/micro/examples/micro_speech/train/train_micro_speech_model.ipynb"><img src="https://www.tensorflow.org/images/colab_logo_32px.png"/>train_micro_speech_model.ipynb</a> |
|
|
||||||
| ------------- |-------------|
|
|
||||||
|
|
||||||
**Estimated Training Time:** ~2 hours.
|
|
||||||
**Advantage:** It allows the use of a free Tesla K80 GPU for training and avoids
|
|
||||||
the need to install dependencies.
|
|
||||||
**Disadvantage:** Your training time is limited as the session can only run
|
|
||||||
upto 12 hours in a row if you keep the browser open and 90 minutes if you close
|
|
||||||
the browser.
|
|
||||||
|
|
||||||
### 2. Use [Google Cloud](https://cloud.google.com/)
|
|
||||||
|
|
||||||
1. Create a Virtual Machine (VM) using a pre-configured Deep Learning VM Image.
|
|
||||||
|
|
||||||
```
|
|
||||||
export IMAGE_FAMILY="tf-latest-cpu"
|
|
||||||
export ZONE="us-west1-b" # Or any other required region
|
|
||||||
export INSTANCE_NAME="model-trainer"
|
|
||||||
export INSTANCE_TYPE="n1-standard-8" # or any other instance type
|
|
||||||
gcloud compute instances create $INSTANCE_NAME \
|
|
||||||
--zone=$ZONE \
|
|
||||||
--image-family=$IMAGE_FAMILY \
|
|
||||||
--image-project=deeplearning-platform-release \
|
|
||||||
--machine-type=$INSTANCE_TYPE \
|
|
||||||
--boot-disk-size=120GB \
|
|
||||||
--min-cpu-platform=Intel\ Skylake
|
|
||||||
```
|
|
||||||
|
|
||||||
2. As soon as instance has been created you can SSH to it:
|
|
||||||
|
|
||||||
```
|
|
||||||
gcloud compute ssh "jupyter@${INSTANCE_NAME}"
|
|
||||||
```
|
|
||||||
|
|
||||||
3. Train a model by following the instructions in the [`train_micro_speech_model.ipynb`](train_micro_speech_model.ipynb)
|
|
||||||
jupyter notebook.
|
|
||||||
|
|
||||||
4. Finally, don't forget to remove the instance when training is done:
|
|
||||||
|
|
||||||
```
|
|
||||||
gcloud compute instances delete "${INSTANCE_NAME}" --zone="${ZONE}"
|
|
||||||
```
|
|
||||||
|
|
||||||
**Estimated Training Time:** ~2 hours (with GPU) and ~1 day (with CPU).
|
|
||||||
**Advantage:** There are no time constraints on how long the training process
|
|
||||||
can take and it avoids the need to install dependencies.
|
|
||||||
**Disadvantage:** Google Cloud isn't free. You need to pay
|
|
||||||
depending on how long you use run the VM and what resources you use.
|
|
||||||
|
|
||||||
## Model Architecture
|
## Model Architecture
|
||||||
|
|
||||||
This is a simple model comprising of a Convolutional 2D layer, a Fully Connected
|
This is a simple model comprising of a Convolutional 2D layer, a Fully Connected
|
||||||
|
@ -197,3 +161,41 @@ python tensorflow/tensorflow/examples/speech_commands/wav_to_features.py \
|
||||||
--window_stride=20 --preprocess=average --quantize=1
|
--window_stride=20 --preprocess=average --quantize=1
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## Other Training Methods
|
||||||
|
|
||||||
|
### Use [Google Cloud](https://cloud.google.com/).
|
||||||
|
|
||||||
|
*Note: Google Cloud isn't free. You need to pay depending on how long you use
|
||||||
|
run the VM and what resources you use.*
|
||||||
|
|
||||||
|
1. Create a Virtual Machine (VM) using a pre-configured Deep Learning VM Image.
|
||||||
|
|
||||||
|
```
|
||||||
|
export IMAGE_FAMILY="tf-latest-cpu"
|
||||||
|
export ZONE="us-west1-b" # Or any other required region
|
||||||
|
export INSTANCE_NAME="model-trainer"
|
||||||
|
export INSTANCE_TYPE="n1-standard-8" # or any other instance type
|
||||||
|
gcloud compute instances create $INSTANCE_NAME \
|
||||||
|
--zone=$ZONE \
|
||||||
|
--image-family=$IMAGE_FAMILY \
|
||||||
|
--image-project=deeplearning-platform-release \
|
||||||
|
--machine-type=$INSTANCE_TYPE \
|
||||||
|
--boot-disk-size=120GB \
|
||||||
|
--min-cpu-platform=Intel\ Skylake
|
||||||
|
```
|
||||||
|
|
||||||
|
2. As soon as instance has been created you can SSH to it:
|
||||||
|
|
||||||
|
```
|
||||||
|
gcloud compute ssh "jupyter@${INSTANCE_NAME}"
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Train a model by following the instructions in the [`train_micro_speech_model.ipynb`](train_micro_speech_model.ipynb)
|
||||||
|
jupyter notebook.
|
||||||
|
|
||||||
|
4. Finally, don't forget to remove the instance when training is done:
|
||||||
|
|
||||||
|
```
|
||||||
|
gcloud compute instances delete "${INSTANCE_NAME}" --zone="${ZONE}"
|
||||||
|
```
|
||||||
|
|