TinyML: Machine Learning with TensorFlow Lite on Arduino and Ultra-Low-Power Microcontrollers 1st Edition
Use the Amazon App to scan ISBNs and compare prices.
"Devoted" by Dean Koontz
For the first time in paperback, from Dean Koontz, the master of suspense, comes an epic thriller about a terrifying killer and the singular compassion it will take to defeat him. | Learn more
Enter your mobile number or email address below and we'll send you a link to download the free Kindle App. Then you can start reading Kindle books on your smartphone, tablet, or computer - no Kindle device required.
To get the free app, enter your mobile phone number.
Frequently bought together
From the Publisher
About This Book
The goal of this book is to show how any developer with basic experience using a command-line terminal and code editor can get started building their own projects running machine learning (ML) on embedded devices.
Who Is This Book Aimed At?
To build a TinyML project, you will need to know a bit about both machine learning and embedded software development. Neither of these are common skills, and very few people are experts on both, so this book will start with the assumption that you have no background in either of these. The only requirements are that you have some familiarity running commands in the terminal (or Command Prompt on Windows), and are able to load a program source file into an editor, make alterations, and save it. Even if that sounds daunting, we walk you through everything we discuss step by step, like a good recipe, including screenshots (and screencasts online) in many cases, so we’re hoping to make this as accessible as possible to a wide audience.
We’ll show you some practical applications of machine learning on embedded devices, using projects like simple speech recognition, detecting gestures with a motion sensor, and detecting people with a camera sensor. We want to get you comfortable with building these programs yourself, and then extending them to solve problems you care about.
For example, you might want to modify the speech recognition to detect barks instead of human speech, or spot dogs instead of people, and we give you ideas on how to tackle those modifications yourself. Our goal is to provide you with the tools you need to start building exciting applications you care about.
What Hardware Do You Need?
You’ll need a laptop or desktop computer with a USB port. This will be your main programming environment, where you edit and compile the programs that you run on the embedded device. You’ll connect this computer to the embedded device using the USB port and a specialized adapter that will depend on what development hardware you’re using. The main computer can be running Windows, Linux, or macOS. For most of the examples we train our machine learning models in the cloud, using Google Colab, so don’t worry about having a specially equipped computer.
You will also need an embedded development board to test your programs on. To do something interesting you’ll need a microphone, accelerometers, or a camera attached, and you want something small enough to build into a realistic prototype project, along with a battery. This was tough to find when we started this book, so we worked together with the chip manufacturer Ambiq and maker retailer SparkFun to produce the $15 SparkFun Edge board. All of the book’s examples will work with this device.
What Software Do You Need?
All of the projects in this book are based around the TensorFlow Lite for Microcontrollers framework. This is a variant of the TensorFlow Lite framework designed to run on embedded devices with only a few tens of kilobytes of memory available. All of the projects are included as examples in the library, and it’s open source, so you can find it on GitHub.
You’ll need some kind of editor to examine and modify your code. If you’re not sure which one you should use, Microsoft’s free VS Code application is a great place to start. It works on macOS, Linux, and Windows, and has a lot of handy features like syntax highlighting and autocomplete. If you already have a favorite editor you can use that, instead; we won’t be doing extensive modifications for any of our projects.
You’ll also need somewhere to enter commands. On macOS and Linux this is known as the terminal, and you can find it in your Applications folder under that name. On Windows it’s known as the Command Prompt, which you can find in your Start menu.
There will also be extra software that you’ll need to communicate with your embedded development board, but this will depend on what device you have. If you’re using either the SparkFun Edge board or an Mbed device, you’ll need to have Python installed for some build scripts, and then you can use GNU Screen on Linux or macOS or Tera Term on Windows to access the debug logging console, showing text output from the embedded device. If you have an Arduino board, everything you need is installed as part of the IDE, so you just need to download the main software package.
About the Author
Pete Warden is technical lead for mobile and embedded TensorFlow. He was CTO and founder of Jetpac, which was acquired by Google in 2014, and previously worked at Apple. He was a founding member of the TensorFlow team, and blogs about practical deep learning at https://petewarden.com.
Daniel Situnayake leads developer advocacy for TensorFlow Lite at Google. He co-founded Tiny Farms, the first US company using automation to produce insect protein at industrial scale. He began his career lecturing in automatic identification and data capture at Birmingham City University.
- Item Weight : 1.75 pounds
- Paperback : 504 pages
- ISBN-13 : 978-1492052043
- Product Dimensions : 7 x 1.01 x 9.19 inches
- ISBN-10 : 1492052043
- Publisher : O'Reilly Media; 1st Edition (December 31, 2019)
- Language: : English
- Best Sellers Rank: #84,663 in Books (See Top 100 in Books)
- Customer Reviews:
Top reviews from the United States
There was a problem filtering reviews right now. Please try again later.
I found this book worthless for building a low power edge device to detect a wake word and move the audio to a higher functioning speech recognition platform. After reading the first few chapters and skimming some others, the best that I could accomplish, from this book, is building a stand alone project that lights an LED based on saying yes or no.
There is no information about getting any data off any of the platforms to another device. No information about MQTT, one of the common protocols for home automation.
Looking at the comments section on the website for one of the boards described in the book I found that everyone had nothing good to say about the "Edge" board. One comment said "how to keep an idiot occupied for an hour." No one really got the platform working to their satisfaction.
One comment referred to a different web site and I looked up the nano BLE sense. No info on any of the websites for this board about tinyML or MQTT. MQTT is not supported over bluetooth to best of my knowledge.
I don't want to build code from scratch without an example. So right now I am at a loss to determine what I would do with the book or any board described in the book. It has been put on my bookshelf and I haven't looked at in months.
Based on discussions with my friend, I am building a home automation system using raspberry PIs and open source code.
Basically, you can follow along the book by running pre-built notebooks in Google Colab to train ML models, then compiling the code to binaries, which you then flashing to the microcontroller - Arduino, SparkFun Edge, and Stm32f7 Discovery Kit are supported with great instructions for all three platforms.
For future versions of the book, I'd like to see:
- instructions for those working in Windows. All the makefiles and build scripts are MacOS/Linux, but providing a facility for those working in Windows environments would be nice, too (Windows Subsystem for Linux, Visual Studio's nmake, cygwin, cloud environment, virtual machine, etc.).
- notebook locations on Github and Google Colab have moved out of 'experimental' status and so the URLs have changed, so some poking around is required to find the code (not hard - the dedicated notebook for the "Hello, world!: example now lives in the /train directory in the repos).
- the book doesn't mention having a serial breakout programmer, just the microcontroller and a USB cable. I had to order the serial adapter separately.
Overall, the book is really well laid out with a friendly voice and demos that are truly fun to work through. The approach to running the examples, then explaining the concepts for running ML on embedded environments and underlying C++ constructs is a great way to present the material. I prefer this than the traditional 6 chapters of iterative building and only at the end you arrive at the finished product. This gives you something to play with right away.
The book does a great job to go deep in this topic and I love the approach it took to cover the relevant topics without going to lengthy rudimentary details that might be academic. I like the way chapters are divided into certain deep dive topics on say, how to deploy a model for a board or the code it generates, that you can revisit again later when you feel like. So, as a result, you can skip ahead, learn about a project, and again come back to review the topic to understand the details. I like this hands-on approach of this ML on a small device topic without sacrificing the quick productivity gain out of this book.
Excellent jobs from the authors and I am looking forward to their next book!
While I did enjoy reading through the projects I didn't enjoy implementing them primarily due to a large amount of boilerplate that I had to setup before I could get started. Perhaps this will change in subsequent releases but for now I'd recommend going through Arduino tutorials or Unity ML agents tutorials to play around with robotics at home.
Top reviews from other countries
I read the book in a few days, but I have not tried any of the examples yet. If you have a little bit of programming experience, you should be able to pick up the concepts easily. There are four worked examples: A simple regression model to emulate a sine wave function, audio ‘wake word’ detection, an image classification model for person detection and a ‘magic wand’, which uses accelerometer data to detect one of a number of hand gestures. They are all quite interesting examples. The book shows you how to port them to one of three different development boards – the Arduino Nano 33 BLE, Sparkfun Edge and STM32F746G.
Whilst this covers a few fundamental concepts, it is not a primer on Neural Networks. If you are serious, I would recommend reading it alongside “Hands-On Machine Learning with Scikit-Learn, Keras & TensorFlow” by Aurelien Geron, and also “Deep Learning with Python” by Francois Chollet. There is a lot more to cover about model architecture, optimisation and tuning hyperparameters, etc. However, when coupled with some other background experience, this book should provide an entry point to building some killer embedded smart devices.
I like it a lot.
The book seems to be a lot of extra explanation for the freely available examples.
The library is very much experimental and far from finished.
The examples are quickly outdated and didn't work well without some bugfixes either.
In my opinion the book should have been published at a later date (with less bugs), there should have been more examples instead of the freely available ones, and the library itself still needs lots of work.