Searching...
English
EnglishEnglish
EspañolSpanish
简体中文Chinese
FrançaisFrench
DeutschGerman
日本語Japanese
PortuguêsPortuguese
ItalianoItalian
한국어Korean
РусскийRussian
NederlandsDutch
العربيةArabic
PolskiPolish
हिन्दीHindi
Tiếng ViệtVietnamese
SvenskaSwedish
ΕλληνικάGreek
TürkçeTurkish
ไทยThai
ČeštinaCzech
RomânăRomanian
MagyarHungarian
УкраїнськаUkrainian
Bahasa IndonesiaIndonesian
DanskDanish
SuomiFinnish
БългарскиBulgarian
עבריתHebrew
NorskNorwegian
HrvatskiCroatian
CatalàCatalan
SlovenčinaSlovak
LietuviųLithuanian
SlovenščinaSlovenian
СрпскиSerbian
EestiEstonian
LatviešuLatvian
فارسیPersian
മലയാളംMalayalam
தமிழ்Tamil
اردوUrdu
AI and Machine Learning for On-Device Development

AI and Machine Learning for On-Device Development

A Programmer's Guide
by Laurence Moroney 2021 326 pages
4.17
6 ratings
Listen
Try Full Access for 7 Days
Unlock listening & more!
Continue

Key Takeaways

1. Machine Learning Fundamentals: From Traditional Programming to AI

Machine learning can be simply described as having code functions figure out their own parameters, instead of the human programmer supplying those parameters.

Paradigm shift. Machine learning represents a fundamental shift from traditional programming. Instead of explicitly defining rules, ML algorithms learn patterns from data. This approach allows computers to tackle complex problems that are difficult to solve with conventional programming.

Learning process. The core of machine learning involves three key steps: making a guess, measuring its accuracy, and optimizing for a better guess. This process is repeated iteratively, allowing the model to improve its performance over time. Through this method, ML can discover intricate patterns and relationships in data that might be invisible to human programmers.

Applications. Machine learning has found applications in various fields, from image and speech recognition to predictive analytics and autonomous systems. Its ability to handle large amounts of data and extract meaningful insights has made it a powerful tool in the age of big data and artificial intelligence.

2. Computer Vision: Enabling Machines to "See" and Understand Images

Computer vision is a huge field, and for the purposes of this book and this chapter, we'll focus narrowly on a couple of core scenarios, where we will use technology to parse the contents of images, either labeling the primary content of an image, or finding items within an image.

Image understanding. Computer vision enables machines to interpret and understand visual information from the world. This field combines techniques from image processing, machine learning, and artificial intelligence to analyze and extract meaningful information from digital images and videos.

Key tasks:

  • Image classification: Categorizing images into predefined classes
  • Object detection: Identifying and locating specific objects within an image
  • Facial recognition: Detecting and identifying human faces
  • Semantic segmentation: Partitioning an image into semantically meaningful parts

Applications. Computer vision has a wide range of applications, including:

  • Autonomous vehicles
  • Medical imaging and diagnosis
  • Quality control in manufacturing
  • Augmented reality
  • Security and surveillance systems

3. Natural Language Processing: Unlocking the Power of Text Analysis

Often you'll want to extract vital information from text. You've no doubt seen apps that can determine when there's an address in a piece of text and automatically generate a link to a map of that address, or others that understand an email address and generate a link that lets you launch your email app to send mail to that address.

Text understanding. Natural Language Processing (NLP) is a branch of AI that focuses on the interaction between computers and human language. It enables machines to understand, interpret, and generate human language in a valuable way.

Key NLP tasks:

  • Entity extraction: Identifying and classifying named entities in text
  • Sentiment analysis: Determining the emotional tone behind a piece of text
  • Text classification: Categorizing text documents into predefined classes
  • Machine translation: Automatically translating text from one language to another
  • Question answering: Generating human-like responses to natural language questions

Applications. NLP has numerous applications across various industries:

  • Chatbots and virtual assistants
  • Email filters and spam detection
  • Content categorization
  • Social media monitoring
  • Language translation services

4. TensorFlow Lite: Bringing ML to Mobile Devices

TensorFlow Lite was created with two main aims. The first—it could be used to convert existing TensorFlow models into a format that was smaller and more compact, with an eye on optimizing them for mobile. The second is to have an efficient runtime for various mobile platforms that could be used for model inference.

Mobile-optimized ML. TensorFlow Lite is a lightweight version of TensorFlow designed specifically for mobile and embedded devices. It allows developers to run machine learning models on devices with limited computational resources and power constraints.

Key features:

  • Model conversion: Transforming TensorFlow models into a mobile-friendly format
  • Optimized inference: Efficient runtime for executing models on mobile devices
  • Cross-platform support: Compatible with Android, iOS, and other embedded systems

Benefits:

  • Reduced latency: On-device inference eliminates network delays
  • Enhanced privacy: Data remains on the user's device
  • Offline functionality: ML capabilities without an internet connection
  • Lower power consumption: Optimized for mobile hardware

5. Creating Custom Models: From Data to Deployable Solutions

Creating models from scratch can be difficult and very time consuming. It's also the realm of pure TensorFlow development and is covered in lots of other books such as my book AI and Machine Learning for Coders (O'Reilly).

Model development process. Creating custom ML models involves several steps, from data collection and preparation to model training and optimization. While building models from scratch can be complex, there are tools and techniques to simplify the process.

Approaches to custom model creation:

  1. TensorFlow Lite Model Maker: Simplifies the process of creating custom models for common scenarios
  2. Cloud AutoML: Automates the model creation process using cloud resources
  3. Transfer learning: Leverages pre-trained models to create new models with less data and training time

Considerations:

  • Data quality and quantity
  • Model architecture selection
  • Hyperparameter tuning
  • Evaluation metrics
  • Model optimization for mobile deployment

6. Implementing ML in Android and iOS Apps

Despite the fact that you're using Kotlin, your source files are in the java directory!. Open this, and you'll see a folder with your package name. Within that you should see your MainActivity.kt file. Double-click this file to open it in the code editor.

Platform-specific integration. Implementing ML models in mobile apps requires understanding the specific frameworks and tools for each platform. For Android, developers typically use Kotlin or Java, while iOS development uses Swift.

Key steps for mobile ML integration:

  1. Model preparation: Converting and optimizing the model for mobile use
  2. Model loading: Efficiently loading the model into the app's memory
  3. Input preprocessing: Preparing data in the format expected by the model
  4. Inference: Running the model to get predictions
  5. Output interpretation: Processing the model's output for use in the app

Challenges:

  • Memory management
  • Performance optimization
  • User experience considerations
  • Platform-specific API usage

7. ML Kit: Simplifying Machine Learning Integration for Mobile Developers

ML Kit is designed to make the ML part of application development as easy as possible, and hopefully the face detection part of this app proved that.

Easy ML integration. ML Kit is a mobile SDK that brings Google's machine learning expertise to Android and iOS apps. It provides a simple way to use ML features without requiring in-depth knowledge of neural networks or model optimization.

Key features:

  • Pre-built APIs for common ML tasks (e.g., face detection, text recognition)
  • Custom model deployment
  • On-device or cloud-based processing options

Benefits for developers:

  • Reduced development time
  • Lower barrier to entry for ML implementation
  • Consistent API across Android and iOS
  • Regular updates and improvements from Google

8. Cloud-Based Models: Leveraging Remote Inference for Mobile Apps

There may be times when you don't want to deploy the model to a mobile device—maybe it's too large or complex for mobile, maybe you want to update it frequently, or maybe you don't want to risk it being reverse-engineered and have your IP used by others.

Remote inference. Cloud-based models offer an alternative to on-device ML, allowing developers to leverage more powerful hardware and larger models while maintaining a lightweight mobile app.

Advantages:

  • Access to more complex models
  • Easier model updates and maintenance
  • Reduced app size and device resource usage
  • Centralized processing for data aggregation and analysis

Considerations:

  • Internet connectivity requirements
  • Latency issues
  • Data privacy and security
  • Costs associated with cloud services

9. Ethics, Fairness, and Privacy in AI: Responsible Development Practices

The promise of AI-based systems is that you will be able to deliver more powerful applications more quickly...but if you do so at the cost of not mitigating bias in your systems, then you could potentially accelerate disparity through the use of AI.

Responsible AI development. As AI and ML become more prevalent in mobile apps, developers must consider the ethical implications of their work. This includes addressing issues of bias, fairness, and privacy throughout the development process.

Key considerations:

  • Data bias: Ensuring training data is representative and unbiased
  • Algorithmic fairness: Designing models that treat all users equitably
  • Privacy protection: Implementing strong data protection measures
  • Transparency: Providing clear explanations of how AI is used in the app

Tools and practices:

  • Fairness indicators: Evaluating model performance across different demographic groups
  • Differential privacy: Protecting individual user data while maintaining useful analytics
  • Model cards: Documenting model characteristics, intended uses, and limitations
  • Continuous monitoring and auditing of deployed models

Last updated:

Review Summary

4.17 out of 5
Average of 6 ratings from Goodreads and Amazon.

AI and Machine Learning for On-Device Development receives high praise from readers, with an overall rating of 4.20 out of 5. One technical reviewer highlights its accessibility for beginners and comprehensive coverage of ML applications on mobile devices. The book is praised for its balanced approach to Android and iOS platforms, as well as its inclusion of ethical considerations in AI development. Readers appreciate the practical exercises and the book's ability to guide them through deploying ML models on devices quickly. The content is described as well-structured and informative for those interested in on-device ML development.

Your rating:
4.49
21 ratings

About the Author

Laurence Moroney is a prolific author with a diverse writing portfolio. Known for his successful programming books, he ventured into young adult fiction with "The Fourth World," which became a #1 Amazon Kindle book and spawned two sequels. His latest work, "Space Cadets," marks the beginning of a new science fiction series. Moroney balances his writing career with his role as a Developer Advocate for Google, a position he greatly values. He continues to work on new projects, including the upcoming sequel "The Quiet World." Moroney's background in technology and his creative storytelling abilities have allowed him to create works that span both technical and fictional genres.

Download PDF

To save this AI and Machine Learning for On-Device Development summary for later, download the free PDF. You can print it out, or read offline at your convenience.
Download PDF
File size: 0.22 MB     Pages: 14

Download EPUB

To read this AI and Machine Learning for On-Device Development summary on your e-reader device or app, download the free EPUB. The .epub digital book format is ideal for reading ebooks on phones, tablets, and e-readers.
Download EPUB
File size: 2.95 MB     Pages: 10
Listen
Now playing
AI and Machine Learning for On-Device Development
0:00
-0:00
Now playing
AI and Machine Learning for On-Device Development
0:00
-0:00
1x
Voice
Speed
Dan
Andrew
Michelle
Lauren
1.0×
+
200 words per minute
Queue
Home
Swipe
Library
Get App
Create a free account to unlock:
Recommendations: Personalized for you
Requests: Request new book summaries
Bookmarks: Save your favorite books
History: Revisit books later
Ratings: Rate books & see your ratings
200,000+ readers
Try Full Access for 7 Days
Listen, bookmark, and more
Compare Features Free Pro
📖 Read Summaries
All summaries are free to read in 40 languages
🎧 Listen to Summaries
Listen to unlimited summaries in 40 languages
❤️ Unlimited Bookmarks
Free users are limited to 4
📜 Unlimited History
Free users are limited to 4
📥 Unlimited Downloads
Free users are limited to 1
Risk-Free Timeline
Today: Get Instant Access
Listen to full summaries of 73,530 books. That's 12,000+ hours of audio!
Day 4: Trial Reminder
We'll send you a notification that your trial is ending soon.
Day 7: Your subscription begins
You'll be charged on Jul 28,
cancel anytime before.
Consume 2.8x More Books
2.8x more books Listening Reading
Our users love us
200,000+ readers
"...I can 10x the number of books I can read..."
"...exceptionally accurate, engaging, and beautifully presented..."
"...better than any amazon review when I'm making a book-buying decision..."
Save 62%
Yearly
$119.88 $44.99/year
$3.75/mo
Monthly
$9.99/mo
Start a 7-Day Free Trial
7 days free, then $44.99/year. Cancel anytime.
Scanner
Find a barcode to scan

Settings
General
Widget
Loading...