Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Machine Learning with Core ML
Machine Learning with Core ML

Machine Learning with Core ML: An iOS developer's guide to implementing machine learning in mobile apps

eBook
€22.99 €32.99
Paperback
€41.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Table of content icon View table of contents Preview book icon Preview Book

Machine Learning with Core ML

Introduction to Apple Core ML

In this chapter, we are going to briefly introduce the framework that we will be using throughout this book - Core ML. But before doing so, we will elaborate on what training and inference are, specifically how they differ; and then we'll look at the motivation for performing machine learning (ML) on the edge, that is, your iOS device.

We will be covering the following topics in the chapter:

  • Highlighting the difference between training a model and using the model for inference 
  • Motivation and opportunities for performing inference on the edge
  • Introducing Core ML and the general workflow 
  • A brief introduction to some ML algorithms
  • Some considerations to keep in mind when developing ML-enabled applications 

Difference between training and inference

The difference between training and inference is similar to that of a student being taught something like algebra at school and then applying it in the real world. In school, the student is given numerous exercises; for each exercise, the student attempts the question and hands his/her answer over to the teacher, who provides feedback indicating whether it is correct or not. Initially, this feedback is likely to be skewed toward the student being wrong more often than right, but after many attempts, as the student starts building his/her understanding of the concepts, the feedback shifts towards mostly being right. At this point, the student is considered to have sufficiently learned algebra and is able to apply it to unseen problems in the real world, where he/she can be confident of the answer based on his/her exposure to the...

Inference on the edge

For those unfamiliar with the term edge computing, it simply refers to computation performed at the end, or edge, of a network as opposed to sending it to a central server for computation. Some examples of edge devices include cars, robots, Internet of Things (IoT), and, of course, smartphones. 

The motivation for performing computation at the edge, where the data resides, is that sending data across the network is expensive and time-consuming; this incurred latency and cost restrict us with what experiences we can deliver to the user. Removing these barriers opens up new applications that would otherwise not be possible. Another benefit of performing inference at the edge is data privacy; removing the need of having to transmit personal data across the network reduces the opportunities that a malicious user has for obtaining it.

Luckily, technology...

A brief introduction to Core ML

With the release of iOS 11 and Core ML, performing inference is just a matter of a few lines of code. Prior to iOS 11, inference was possible, but it required some work to take a pre-trained model and port it across using an existing framework such as Accelerate or metal performance shaders (MPSes). Accelerate and MPSes are still used under the hood by Core ML, but Core ML takes care of deciding which underlying framework your model should use (Accelerate using the CPU for memory-heavy tasks and MPSes using the GPU for compute-heavy tasks). It also takes care of abstracting a lot of the details away; this layer of abstraction is shown in the following diagram: 

There are additional layers too; iOS 11 has introduced and extended domain-specific layers that further abstract a lot of the common tasks you may use when working with image...

Learning algorithms 

In Chapter 1Introduction to Machine Learning, we saw many different types of learning algorithms and learned that ML is really a process of automatically discovering rules given a set of examples. The main components required for this process, specifically for supervised learning, include: 

  • Input data points: For image classification, we would require images of the domain we want to classify, for example, animals. 
  • The expected outputs for these inputs: Continuing from our previous example of image classification of animals, the expected outputs could be labels associated with each of the images, for example, cat, dog, and many more. 
  • A ML algorithm: This is the algorithm used to automatically learn how to transform the input data points into a meaningful output. These derived sets of rules are what we call the...

Considerations 

When performing ML on the edge, you lose some of the luxuries you tend to have when running on a more powerful device (albeit this is shifting all the time). Here is a list of considerations to keep in mind:

  • Model size: Previously, we walked through building a simple linear regression model. The model itself consists of two floats (bias and weight coefficients), which of course are negligible in terms of memory requirements. But, as you dive into the world of deep learning, it's common to find models hundreds of megabytes in size. For example, the VGG16 model is a 16-layer conventional neural network architecture trained on the ImageNet dataset used for image classification, available on Apple's site. It is just over 500 megabytes. Currently, Apple allows apps 2 gigabytes in size, but asking your user to download such a large file...

Summary

In this chapter, we discussed the difference between training and inference, along with the typical ML workflow and where Core ML fits in. We also saw how Core ML is not just a single framework, but rather a suite of tools that facilitate getting pretrained models into the iOS platform and making them available to your application via a familiar and simple interface. Thus, it democratizes ML and puts it into the hands of many iOS app developers.

It has been suggested that the explosion in diverse apps contributed to the success of the adoption of smartphones; if this is true, then prepare yourself for the next explosion of AI-enhanced apps. And take comfort knowing that you are in the perfect place to begin and lead this journey, where we will explore many concepts and examples related to computer vision using Core ML, including these:

  • Recognizing objects...
Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Explore the concepts of machine learning and Apple’s Core ML APIs
  • Use Core ML to understand and transform images and videos
  • Exploit the power of using CNN and RNN in iOS applications

Description

Core ML is a popular framework by Apple, with APIs designed to support various machine learning tasks. It allows you to train your machine learning models and then integrate them into your iOS apps. Machine Learning with Core ML is a fun and practical guide that not only demystifies Core ML but also sheds light on machine learning. In this book, you’ll walk through realistic and interesting examples of machine learning in the context of mobile platforms (specifically iOS). You’ll learn to implement Core ML for visual-based applications using the principles of transfer learning and neural networks. Having got to grips with the basics, you’ll discover a series of seven examples, each providing a new use-case that uncovers how machine learning can be applied along with the related concepts. By the end of the book, you will have the skills required to put machine learning to work in their own applications, using the Core ML APIs

Who is this book for?

Machine Learning with Core ML is for you if you are an intermediate iOS developer interested in applying machine learning to your mobile apps. This book is also for those who are machine learning developers or deep learning practitioners who want to bring the power of neural networks in their iOS apps. Some exposure to machine learning concepts would be beneficial but not essential, as this book acts as a launchpad into the world of machine learning for developers.

What you will learn

  • Understand components of an ML project using algorithms, problems, and data
  • Master Core ML by obtaining and importing machine learning model, and generate classes
  • Prepare data for machine learning model and interpret results for optimized solutions
  • Create and optimize custom layers for unsupported layers
  • Apply CoreML to image and video data using CNN
  • Learn the qualities of RNN to recognize sketches, and augment drawing
  • Use Core ML transfer learning to execute style transfer on images

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Jun 28, 2018
Length: 378 pages
Edition : 1st
Language : English
ISBN-13 : 9781788835596
Vendor :
Apple
Category :
Tools :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want

Product Details

Publication date : Jun 28, 2018
Length: 378 pages
Edition : 1st
Language : English
ISBN-13 : 9781788835596
Vendor :
Apple
Category :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 116.97
Machine Learning with Swift
€32.99
Machine Learning with Core ML
€41.99
Intelligent Mobile Projects with TensorFlow
€41.99
Total 116.97 Stars icon

Table of Contents

11 Chapters
Introduction to Machine Learning Chevron down icon Chevron up icon
Introduction to Apple Core ML Chevron down icon Chevron up icon
Recognizing Objects in the World Chevron down icon Chevron up icon
Emotion Detection with CNNs Chevron down icon Chevron up icon
Locating Objects in the World Chevron down icon Chevron up icon
Creating Art with Style Transfer Chevron down icon Chevron up icon
Assisted Drawing with CNNs Chevron down icon Chevron up icon
Assisted Drawing with RNNs Chevron down icon Chevron up icon
Object Segmentation Using CNNs Chevron down icon Chevron up icon
An Introduction to Create ML Chevron down icon Chevron up icon
Other Books You May Enjoy Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Full star icon Full star icon Full star icon 5
(1 Ratings)
5 star 100%
4 star 0%
3 star 0%
2 star 0%
1 star 0%
Yiannis Aug 21, 2018
Full star icon Full star icon Full star icon Full star icon Full star icon 5
With Core ML, iOS (as of iOS 11) now allows iPhone developers to easily integrate trained machine learning models into their apps with a few line of code. As Machine Learning is the talk of the town nowadays, it's a well sought-after skill for any iOS developer to know how they can introduce some AI/ML magic into their apps. And this is exactly what this book achieves and it does so in a way that:1. Doesn't require much knowledge of machine learning. As a matter of fact, it delivers a short and sweet introduction of key ML concepts that is all you need to know to understand how to utilise trained models.2. Explains with clear examples what the possibilities are. Examples are easy to follow and run on your device. As seeing is believing, these examples can offer food for thought for you or your clients (if you are in the business for developing apps for other).By far the best book about Core ML in the market!
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.