With iOS 10, Apple added tools for creating neural networks on iOS, but how can you use these tools to solve real-world problems? In this talk will examine a real-world problem that can be solved using neural networks and machine learning. From training a neural network on industry standard platforms, through to migrating the trained model to iOS, this talk will show how machine learning can be used to create the next generation of intelligent apps.
Some knowledge of the basic concepts of Machine Learning would be helpful but is not required.
2. Keith Moon - Senior iOS Developer
Machine Learning for
iOS Developers
UnitedDefConf - Minsk
April 2017
3. 3
• iOS Developer since 2010
• Worked with BBC News, Hotels.com and Travelex
• “Swift 3 Cookbook” to be published by Pakt
Who am I?
@keefmoon
4. 4
• Help users discover great local food
• Make it quick and easy to order from a wide variety of takeaways
• Available on:
–Web
–iOS
–tvOS
–Android
–Amazon Echo
What is Just Eat?
3
5. 5
• Australia
• Brazil
• Canada
• Denmark
• France
• Ireland
• Italy
• Mexico
What is Just Eat?
Global Business
• New Zealand
• Norway
• Spain
• Switzerland
• UK
6. 8
What this talk isn’t?
• Not a ML expert
• Not a Python expert
• Not great at Maths
• Not a deep dive into ML
So what is this talk?
7. So what is this talk?
9
• ML from an iOS developer’s point of view
• High level overview of ML
• What features are appropriate uses of ML?
• How can you use ML in your apps?
• Current state of ML tools
• What does the future hold?
25. Your
App
API
Adding a ML Feature
29
What are my options?
Train
Use
1) Managed Machine Learning driven API
26. 30
• No ML knowledge required
• Simple to implement
• Light on resources
• Only solves common ML problems
• Third-Party dependancy
• Needs connectivity
• Data ownership issues
• No control over model improvement
Adding a ML Feature What are my options?
1) Managed Machine Learning driven API
27. 31
Adding a ML Feature What are my options?
2) Custom Model Trained and Used on Server
Your
App
API
Train
Use
28. 32
• Can customise the model to your
needs
• Make use of open source models
• Light on mobile resources
• You control the data
• You control model improvement
• Knowledge of ML tools / Python
needed
• Server management overhead
• App friendly API needed
• Needs connectivity
Adding a ML Feature What are my options?
2) Custom Model Trained and Used on Server
29. 33
Adding a ML Feature What are my options?
3) Custom Model Trained on Server. Used on Phone.
API
Train
Trained ModelAccelerate
Framework
Metal
Framework
GPU
CPU
30. 34
• Can customise the model to your
needs
• Make use of open source models
• User can control the data
• Can work offline
• Knowledge of ML tools / Python needed
• Server management overhead
• Need to transfer complex model to phone
• May limit the scope of model
improvement
Adding a ML Feature What are my options?
3) Custom Model Trained on Server. Used on Phone.
31. 36
Adding a ML Feature What are my options?
3) Custom Model Trained on Server. Used on Phone.
2) Custom Model Trained and Used on Server
1) Managed Machine Learning driven API
32. Future of Machine Learning on iOS
● Easier model transfer from server to phone
● Trainable network APIs from Apple
● Ability to plug and play ML models together
● Further development of Swift ML tools
37
33. References
Machine Learning APIs:
Google Prediction: https://cloud.google.com/prediction
Google Natural Language: https://cloud.google.com/natural-language
Microsoft Cognitive Services: https://www.microsoft.com/cognitive-services
Amazon ML: https://aws.amazon.com/documentation/machine-learning
IBM Watson: https://www.ibm.com/watson/developercloud
Open Source Model:
Tensor Flow Models: https://github.com/tensorflow/models
FaceNet for TensorFlow: https://github.com/davidsandberg/facenet
38
34. References
Machine Learning Frameworks:
Torch: http://torch.ch
TensorFlow: https://www.tensorflow.org
Caffe: https://github.com/BVLC/caffe
Awesome Machine Learning resources: https://github.com/josephmisiti/awesome-machine-learning
Hosting:
Amazon Web Services: https://aws.amazon.com
Amazon Deep Learning AMI - Ubuntu Edition https://aws.amazon.com/marketplace/pp/B06VSPXKDX
Digital Ocean https://www.digitalocean.com
39
35. References
Machine Learning Frameworks on iOS:
Torch: https://github.com/clementfarabet/torch-ios
TensorFlow: https://github.com/tensorflow/tensorflow/tree/master/tensorflow/contrib/ios_examples
http://www.mattrajca.com/2016/11/25/getting-started-with-deep-mnist-and-tensorflow-on-ios.html
Caffe: https://github.com/noradaiko/caffe-ios-sample
Using Metal Performance Shaders with a TensorFlow trained model:
https://developer.apple.com/library/content/samplecode/MPSCNNHelloWorld
Neural Networks and Accelerate: https://developer.apple.com/videos/play/wwdc2016/715
BNNS in Accelerate: https://developer.apple.com/reference/accelerate/bnns
List of ML resources for iOS: https://github.com/alexsosn/iOS_ML
40