1.. _tensorflow_hello_world: 2 3TensorFlow Lite Micro Hello World sample 4######################################## 5 6Overview 7******** 8 9This sample TensorFlow application replicates a sine wave and 10demonstrates the absolute basics of using TensorFlow Lite Micro. 11 12The model included with the sample is trained to replicate a 13sine function and generates x values to print alongside the 14y values predicted by the model. The x values iterate from 0 to 15an approximation of 2π. 16 17The sample also includes a full end-to-end workflow of training 18a model and converting it for use with TensorFlow Lite Micro for 19running inference on a microcontroller. 20 21.. Note:: 22 This README and sample have been modified from 23 `the TensorFlow Hello World sample for Zephyr`_. 24 25.. _the TensorFlow Hello World sample for Zephyr: 26 https://github.com/tensorflow/tflite-micro/tree/main/tensorflow/lite/micro/examples/hello_world 27 28Building and Running 29******************** 30 31This sample should work on most boards since it does not rely 32on any sensors. 33 34This application can be built and executed on QEMU as follows: 35 36.. zephyr-app-commands:: 37 :zephyr-app: samples/modules/tensorflow/hello_world 38 :host-os: unix 39 :board: qemu_x86 40 :goals: run 41 :compact: 42 43Exit QEMU by pressing :kbd:`CTRL+A` :kbd:`x`. 44 45Sample Output 46============= 47 48.. code-block:: console 49 50 ... 51 52 x_value: 1.0995567*2^1, y_value: 1.6951603*2^-1 53 54 x_value: 1.2566366*2^1, y_value: 1.1527088*2^-1 55 56 x_value: 1.4137159*2^1, y_value: 1.1527088*2^-2 57 58 x_value: 1.5707957*2^1, y_value: -1.0849024*2^-6 59 60 x_value: 1.7278753*2^1, y_value: -1.0509993*2^-2 61 62 ... 63 64The modified sample prints 50 generated-x-and-predicted-y pairs. 65 66Modifying Sample for Your Own Project 67************************************* 68 69It is recommended that you copy and modify one of the two TensorFlow 70samples when creating your own TensorFlow project. To build with 71TensorFlow, you must enable the below Kconfig options in your :file:`prj.conf`. 72 73:file:`prj.conf`: 74 75.. code-block:: console 76 77 CONFIG_CPLUSPLUS=y 78 CONFIG_NEWLIB_LIBC=y 79 CONFIG_TENSORFLOW_LITE_MICRO=y 80 81Training 82******** 83Follow the instructions in the :file:`train/` directory to train your 84own model for use in the sample. 85