TinyML Cookbook
eBook - ePub

TinyML Cookbook

Gian Marco Iodice

Share book
  1. 344 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

TinyML Cookbook

Gian Marco Iodice

Book details
Book preview
Table of contents
Citations

About This Book

Work through over 50 recipes to develop smart applications on Arduino Nano 33 BLE Sense and Raspberry Pi Pico using the power of machine learning

Key Features

  • Train and deploy ML models on Arduino Nano 33 BLE Sense and Raspberry Pi Pico
  • Work with different ML frameworks such as TensorFlow Lite for Microcontrollers and Edge Impulse
  • Explore cutting-edge technologies such as microTVM and Arm Ethos-U55 microNPU

Book Description

This book explores TinyML, a fast-growing field at the unique intersection of machine learning and embedded systems to make AI ubiquitous with extremely low-powered devices such as microcontrollers.The TinyML Cookbook starts with a practical introduction to this multidisciplinary field to get you up to speed with some of the fundamentals for deploying intelligent applications on Arduino Nano 33 BLE Sense and Raspberry Pi Pico. As you progress, you'll tackle various problems that you may encounter while prototyping microcontrollers, such as controlling the LED state with GPIO and a push-button, supplying power to microcontrollers with batteries, and more. Next, you'll cover recipes relating to temperature, humidity, and the three "V" sensors (Voice, Vision, and Vibration) to gain the necessary skills to implement end-to-end smart applications in different scenarios. Later, you'll learn best practices for building tiny models for memory-constrained microcontrollers. Finally, you'll explore two of the most recent technologies, microTVM and microNPU that will help you step up your TinyML game.By the end of this book, you'll be well-versed with best practices and machine learning frameworks to develop ML apps easily on microcontrollers and have a clear understanding of the key aspects to consider during the development phase.

What you will learn

  • Understand the relevant microcontroller programming fundamentals
  • Work with real-world sensors such as the microphone, camera, and accelerometer
  • Run on-device machine learning with TensorFlow Lite for Microcontrollers
  • Implement an app that responds to human voice with Edge Impulse
  • Leverage transfer learning to classify indoor rooms with Arduino Nano 33 BLE Sense
  • Create a gesture-recognition app with Raspberry Pi Pico
  • Design a CIFAR-10 model for memory-constrained microcontrollers
  • Run an image classifier on a virtual Arm Ethos-U55 microNPU with microTVM

Who this book is for

This book is for machine learning developers/engineers interested in developing machine learning applications on microcontrollers through practical examples quickly. Basic familiarity with C/C++, the Python programming language, and the command-line interface (CLI) is required. However, no prior knowledge of microcontrollers is necessary.

]]>

Frequently asked questions

How do I cancel my subscription?
Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
Can/how do I download books?
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
What is the difference between the pricing plans?
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
What is Perlego?
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Do you support text-to-speech?
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Is TinyML Cookbook an online PDF/ePUB?
Yes, you can access TinyML Cookbook by Gian Marco Iodice in PDF and/or ePUB format, as well as other popular books in Computer Science & Computer Science General. We have over one million books available in our catalogue for you to explore.

Information

Chapter 1: Getting Started with TinyML

Here we are, with our first step into the world of TinyML.
This chapter starts with an overview of this emerging field, presenting the opportunities and challenges to bring machine learning (ML) to extremely low-power microcontrollers.
The body of this chapter focuses on the fundamental elements behind ML, power consumption, and microcontrollers that make TinyML unique and different from conventional ML in the cloud, desktops, or even smartphones. In particular, the Programming microcontrollers section will be crucial for those with little experience in embedded programming.
After introducing the TinyML building blocks, we shall set up the development environment for a simple LED application, which will officially mark the beginning of our practical TinyML journey.
In contrast to what we will find in the following chapters, this chapter has a more theoretical structure to get you familiar with the concepts and terminology of this fast-growing technology.
In this chapter, we're going to cover the following topics:
  • Introducing TinyML
  • Summary of deep learning
  • Learning the difference between power and energy
  • Programming microcontrollers
  • Presenting Arduino Nano 33 BLE Sense and Raspberry Pi Pico
  • Setting up Arduino Web Editor, TensorFlow, and Edge Impulse
  • Running a sketch on Arduino Nano and Raspberry Pi Pico

Technical requirements

To complete the practical example in this chapter, we need the following:
  • Arduino Nano 33 BLE Sense board
  • Raspberry Pi Pico board
  • Micro-USB cable
  • Laptop/PC with either Ubuntu 18.04 or Windows 10 on x86-64

Introducing TinyML

Throughout all the recipes presented in this book, we will give practical solutions for tiny machine learning, or, as we will refer to it, TinyML. In this section, we will learn what TinyML is and the vast opportunities it brings.

What is TinyML?

TinyML is the set of technologies in ML and embedded systems to make use of smart applications on extremely low-power devices. Generally, these devices have limited memory and computational capabilities, but they can sense the physical environment through sensors and act based on the decisions taken by ML algorithms.
In TinyML, ML and the deployment platform are not just two independent entities but rather entities that need to know each other at best. In fact, designing an ML architecture without considering the target device characteristics will make it challenging to deploy effective and working TinyML applications.
On the other hand, it would be impossible to design power-efficient processors to expand the ML capabilities of these devices without knowing the software algorithms involved.
This book will consider microcontrollers as the target device for TinyML, and the following subsection will help motivate our choice.

Why ML on microcontrollers?

The first and foremost reason for choosing microcontrollers is their popularity in various fields, such as automotive, consumer electronics, kitchen appliances, healthcare, and telecommunications. Nowadays, microcontrollers are everywhere and also invisible in our day-to-day electronic devices.
With the rise of the internet of things (IoT), microcontrollers saw exponential market growth. In 2018, the market research company IDC (https://www.idc.com) reported 28.1 billion microcontrollers sold worldwide and forecasted growth to 38.2 billion by 2023 (www.arm.com/blogs/blueprint/tinyML). Those are impressive numbers considering that the smartphone and PC markets reported 1.5 billion and 67.2 million devices, respectively, sold in the same year.
Therefore, TinyML represents a significant step forward for IoT devices, driving the proliferation of tiny connected objects capable of performing ML tasks locally.
The second reason for choosing microcontrollers is that they are inexpensive, easy to program and are powerful enough to run sophisticated deep learning (DL) algorithms.
However, why can't we offload the computation to the cloud since it is much more performant? In other words, why do we need to run ML locally?

Why run ML locally?

There are three main answers to this question – latency, power consumption, and privacy:
  • Reducing latency: Sending data back and forth to and from the cloud is not instant and could affect applications that must respond reliably within a time frame.
  • Reducing power consumption: Sending and receiving data to and from the cloud is not power-efficient even when using low-power communication protocols such as Bluetooth.
In the following stacked bar chart, we report the power consumption breakdown for the onboard components on the Arduino Nano 33 BLE Sense board, one of the two microcontroller boards employed in this book:
Figure 1.1 – Power consumption breakdown for the Arduino Nano 33 BLE Sense board
Figure 1.1 – Power consumption breakdown for the Arduino Nano 33 BLE Sense board
As we can see from the power consumption breakdown, the CPU computation is more power-efficie...

Table of contents