Preface |
|
xiii | |
1 Introduction |
|
1 | (4) |
|
|
3 | (1) |
|
|
4 | (1) |
2 Getting Started |
|
5 | (6) |
|
Who Is This Book Aimed At? |
|
|
5 | (1) |
|
What Hardware Do You Need? |
|
|
6 | (1) |
|
What Software Do You Need? |
|
|
7 | (1) |
|
What Do We Hope You'll Learn? |
|
|
8 | (3) |
3 Getting Up to Speed on Machine Learning |
|
11 | (18) |
|
What Machine Learning Actually Is |
|
|
12 | (1) |
|
The Deep Learning Workflow |
|
|
13 | (15) |
|
|
14 | (1) |
|
|
14 | (2) |
|
Design a Model Architecture |
|
|
16 | (5) |
|
|
21 | (5) |
|
|
26 | (1) |
|
|
26 | (1) |
|
Evaluate and Troubleshoot |
|
|
27 | (1) |
|
|
28 | (1) |
4 The "Hello World" of TinyML: Building and Training a Model |
|
29 | (38) |
|
|
30 | (2) |
|
Our Machine Learning Toolchain |
|
|
32 | (2) |
|
Python and Jupyter Notebooks |
|
|
32 | (1) |
|
|
33 | (1) |
|
|
33 | (1) |
|
|
34 | (12) |
|
|
35 | (3) |
|
|
38 | (3) |
|
|
41 | (1) |
|
|
42 | (4) |
|
|
46 | (14) |
|
|
48 | (1) |
|
|
49 | (5) |
|
|
54 | (4) |
|
|
58 | (2) |
|
Converting the Model for TensorFlow Lite |
|
|
60 | (5) |
|
|
64 | (1) |
|
|
65 | (2) |
5 The "Hello World" of TinyML: Building an Application |
|
67 | (28) |
|
Walking Through the Tests |
|
|
68 | (17) |
|
|
69 | (1) |
|
|
70 | (1) |
|
Getting Ready to Log Data |
|
|
70 | (2) |
|
|
72 | (2) |
|
Creating an AllOpsResolver |
|
|
74 | (1) |
|
|
74 | (1) |
|
|
75 | (1) |
|
Inspecting the Input Tensor |
|
|
75 | (3) |
|
Running Inference on an Input |
|
|
78 | (2) |
|
|
80 | (2) |
|
|
82 | (3) |
|
|
85 | (1) |
|
Walking Through the Source |
|
|
86 | (7) |
|
Starting with main_functions.cc |
|
|
87 | (3) |
|
Handling Output with output_handler.cc |
|
|
90 | (1) |
|
Wrapping Up main_functions.cc |
|
|
91 | (1) |
|
|
91 | (1) |
|
|
92 | (1) |
|
|
93 | (2) |
6 The "Hello World" of TinyML: Deploying to Microcontrollers |
|
95 | (32) |
|
What Exactly Is a Microcontroller? |
|
|
96 | (1) |
|
|
97 | (9) |
|
Handling Output on Arduino |
|
|
98 | (3) |
|
|
101 | (5) |
|
|
106 | (1) |
|
|
106 | (13) |
|
Handling Output on SparkFun Edge |
|
|
107 | (3) |
|
|
110 | (7) |
|
|
117 | (1) |
|
|
118 | (1) |
|
|
118 | (1) |
|
ST Microelectronics STM32F746G Discovery Kit |
|
|
119 | (7) |
|
Handling Output on STM32F746G |
|
|
119 | (5) |
|
|
124 | (2) |
|
|
126 | (1) |
|
|
126 | (1) |
7 Wake-Word Detection: Building an Application |
|
127 | (54) |
|
|
128 | (1) |
|
|
129 | (4) |
|
|
130 | (2) |
|
|
132 | (1) |
|
Walking Through the Tests |
|
|
133 | (19) |
|
|
134 | (4) |
|
|
138 | (1) |
|
|
139 | (6) |
|
|
145 | (6) |
|
|
151 | (1) |
|
|
152 | (4) |
|
|
156 | (1) |
|
Deploying to Microcontrollers |
|
|
156 | (24) |
|
|
157 | (8) |
|
|
165 | (10) |
|
ST Microelectronics STM32F746G Discovery Kit |
|
|
175 | (5) |
|
|
180 | (1) |
8 Wake-Word Detection: Training a Model |
|
181 | (40) |
|
|
182 | (15) |
|
|
182 | (15) |
|
Using the Model in Our Project |
|
|
197 | (5) |
|
|
197 | (1) |
|
|
198 | (1) |
|
Updating command_responder.cc |
|
|
198 | (3) |
|
Other Ways to Run the Scripts |
|
|
201 | (1) |
|
|
202 | (12) |
|
|
202 | (4) |
|
How Does Feature Generation Work? |
|
|
206 | (2) |
|
Understanding the Model Architecture |
|
|
208 | (5) |
|
Understanding the Model Output |
|
|
213 | (1) |
|
Training with Your Own Data |
|
|
214 | (5) |
|
The Speech Commands Dataset |
|
|
215 | (1) |
|
Training on Your Own Dataset |
|
|
216 | (1) |
|
How to Record Your Own Audio |
|
|
216 | (2) |
|
|
218 | (1) |
|
|
219 | (1) |
|
|
219 | (2) |
9 Person Detection: Building an Application |
|
221 | (38) |
|
|
222 | (2) |
|
|
224 | (3) |
|
|
224 | (1) |
|
|
225 | (2) |
|
Walking Through the Tests |
|
|
227 | (6) |
|
|
227 | (4) |
|
|
231 | (1) |
|
|
232 | (1) |
|
|
233 | (3) |
|
Deploying to Microcontrollers |
|
|
236 | (21) |
|
|
236 | (10) |
|
|
246 | (11) |
|
|
257 | (2) |
10 Person Detection: Training a Model |
|
259 | (20) |
|
|
259 | (1) |
|
Setting Up a Google Cloud Platform Instance |
|
|
260 | (8) |
|
Training Framework Choice |
|
|
268 | (1) |
|
|
269 | (1) |
|
|
270 | (2) |
|
|
272 | (2) |
|
|
274 | (1) |
|
Exporting the Model to TensorFlow Lite |
|
|
274 | (3) |
|
Exporting to a GraphDef Protobuf File |
|
|
274 | (1) |
|
|
275 | (1) |
|
Quantizing and Converting to TensorFlow Lite |
|
|
275 | (1) |
|
Converting to a C Source File |
|
|
276 | (1) |
|
Training for Other Categories |
|
|
277 | (1) |
|
Understanding the Architecture |
|
|
277 | (1) |
|
|
278 | (1) |
11 Magic Wand: Building an Application |
|
279 | (50) |
|
|
282 | (1) |
|
|
283 | (2) |
|
|
284 | (1) |
|
|
284 | (1) |
|
Walking Through the Tests |
|
|
285 | (10) |
|
|
286 | (3) |
|
The Accelerometer Handler |
|
|
289 | (2) |
|
|
291 | (3) |
|
|
294 | (1) |
|
|
295 | (3) |
|
Deploying to Microcontrollers |
|
|
298 | (29) |
|
|
298 | (14) |
|
|
312 | (15) |
|
|
327 | (2) |
12 Magic Wand: Training a Model |
|
329 | (26) |
|
|
330 | (9) |
|
|
330 | (9) |
|
Other Ways to Run the Scripts |
|
|
339 | (1) |
|
|
339 | (10) |
|
|
339 | (3) |
|
Understanding the Model Architecture |
|
|
342 | (7) |
|
Training with Your Own Data |
|
|
349 | (4) |
|
|
349 | (3) |
|
Modifying the Training Scripts |
|
|
352 | (1) |
|
|
352 | (1) |
|
|
352 | (1) |
|
|
353 | (2) |
|
Learning Machine Learning |
|
|
353 | (1) |
|
|
354 | (1) |
13 TensorFlow Lite for Microcontrollers |
|
355 | (38) |
|
What Is TensorFlow Lite for Microcontrollers? |
|
|
355 | (6) |
|
|
355 | (1) |
|
|
356 | (1) |
|
TensorFlow Lite for Microcontrollers |
|
|
356 | (1) |
|
|
357 | (2) |
|
Why Is the Model Interpreted? |
|
|
359 | (1) |
|
|
360 | (1) |
|
|
361 | (9) |
|
|
362 | (4) |
|
|
366 | (3) |
|
|
369 | (1) |
|
Supporting a New Hardware Platform |
|
|
370 | (6) |
|
|
371 | (2) |
|
|
373 | (2) |
|
|
375 | (1) |
|
Integrating with the Makefile Build |
|
|
376 | (1) |
|
Supporting a New IDE or Build System |
|
|
376 | (1) |
|
Integrating Code Changes Between Projects and Repositories |
|
|
377 | (2) |
|
Contributing Back to Open Source |
|
|
379 | (1) |
|
Supporting New Hardware Accelerators |
|
|
380 | (1) |
|
Understanding the File Format |
|
|
381 | (7) |
|
|
382 | (6) |
|
Porting TensorFlow Lite Mobile Ops to Micro |
|
|
388 | (4) |
|
Separate the Reference Code |
|
|
389 | (1) |
|
Create a Micro Copy of the Operator |
|
|
389 | (1) |
|
Port the Test to the Micro Framework |
|
|
390 | (1) |
|
|
391 | (1) |
|
Add Your Op to AllOpsResolver |
|
|
391 | (1) |
|
|
391 | (1) |
|
|
392 | (1) |
14 Designing Your Own TinyML Applications |
|
393 | (8) |
|
|
393 | (1) |
|
Do You Need a Microcontroller, or Would a Larger Device Work? |
|
|
394 | (1) |
|
Understanding What's Possible |
|
|
395 | (1) |
|
Follow in Someone Else's Footsteps |
|
|
395 | (1) |
|
Find Some Similar Models to Train |
|
|
396 | (1) |
|
|
397 | (1) |
|
|
398 | (1) |
|
Get It Working on the Desktop First |
|
|
399 | (2) |
15 Optimizing Latency |
|
401 | (14) |
|
First Make Sure It Matters |
|
|
401 | (1) |
|
|
402 | (1) |
|
|
402 | (2) |
|
|
403 | (1) |
|
How to Speed Up Your Model |
|
|
404 | (1) |
|
|
404 | (2) |
|
|
406 | (1) |
|
|
407 | (2) |
|
|
407 | (2) |
|
|
409 | (5) |
|
Look for Implementations That Are Already Optimized |
|
|
409 | (1) |
|
Write Your Own Optimized Implementation |
|
|
409 | (3) |
|
Taking Advantage of Hardware Features |
|
|
412 | (1) |
|
Accelerators and Coprocessors |
|
|
413 | (1) |
|
Contributing Back to Open Source |
|
|
414 | (1) |
|
|
414 | (1) |
16 Optimizing Energy Usage |
|
415 | (8) |
|
|
415 | (4) |
|
Typical Component Power Usage |
|
|
416 | (1) |
|
|
417 | (2) |
|
Measuring Real Power Usage |
|
|
419 | (1) |
|
Estimating Power Usage for a Model |
|
|
419 | (1) |
|
|
420 | (2) |
|
|
420 | (1) |
|
|
421 | (1) |
|
|
422 | (1) |
17 Optimizing Model and Binary Size |
|
423 | (14) |
|
Understanding Your System's Limits |
|
|
423 | (1) |
|
|
424 | (2) |
|
|
424 | (1) |
|
|
425 | (1) |
|
Ballpark Figures for Model Accuracy and Size on Different Problems |
|
|
426 | (2) |
|
|
427 | (1) |
|
Accelerometer Predictive Maintenance Model |
|
|
427 | (1) |
|
Person Presence Detection |
|
|
427 | (1) |
|
|
428 | (1) |
|
Reducing the Size of Your Executable |
|
|
428 | (6) |
|
|
429 | (1) |
|
How Much Space Is Tensorflow Lite for Microcontrollers Taking? |
|
|
429 | (1) |
|
|
430 | (1) |
|
Understanding the Size of Individual Functions |
|
|
431 | (3) |
|
|
434 | (1) |
|
|
434 | (1) |
|
|
435 | (2) |
18 Debugging |
|
437 | (10) |
|
Accuracy Loss Between Training and Deployment |
|
|
437 | (3) |
|
Preprocessing Differences |
|
|
437 | (2) |
|
|
439 | (1) |
|
|
440 | (1) |
|
|
440 | (2) |
|
Are the Differences a Problem? |
|
|
440 | (1) |
|
|
441 | (1) |
|
Compare Against a Baseline |
|
|
441 | (1) |
|
|
442 | (1) |
|
Mysterious Crashes and Hangs |
|
|
442 | (3) |
|
|
443 | (1) |
|
|
443 | (1) |
|
|
444 | (1) |
|
|
444 | (1) |
|
|
445 | (2) |
19 Porting Models from TensorFlow to TensorFlow Lite |
|
447 | (6) |
|
Understand What Ops Are Needed |
|
|
447 | (1) |
|
Look at Existing Op Coverage in Tensorflow Lite |
|
|
448 | (1) |
|
Move Preprocessing and Postprocessing into Application Code |
|
|
449 | (1) |
|
Implement Required Ops if Necessary |
|
|
450 | (1) |
|
|
450 | (1) |
|
|
450 | (3) |
20 Privacy, Security, and Deployment |
|
453 | (8) |
|
|
453 | (3) |
|
The Privacy Design Document |
|
|
454 | (2) |
|
|
456 | (1) |
|
|
456 | (2) |
|
|
457 | (1) |
|
|
458 | (1) |
|
Moving from a Development Board to a Product |
|
|
458 | (1) |
|
|
459 | (2) |
21 Learning More |
|
461 | (4) |
|
|
461 | (1) |
|
|
461 | (1) |
|
|
462 | (1) |
|
|
462 | (1) |
|
|
462 | (1) |
|
|
462 | (1) |
|
|
463 | (2) |
A Using and Generating an Arduino Library Zip |
|
465 | (2) |
B Capturing Audio on Arduino |
|
467 | (8) |
Index |
|
475 | |