Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
从 Swift 到机器学习
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Wei Wang
September 15, 2018
Programming
1.1k
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
从 Swift 到机器学习
Wei Wang
September 15, 2018
More Decks by Wei Wang
See All by Wei Wang
網路之難,難於上青天 - iPlayground 2019
onevcat
11
5.4k
GMTC 2019 - 在分歧中发展,2019 我们能用 Swift 做什么
onevcat
0
1.2k
iOS Dev - The Dark Side
onevcat
0
170
面向协议编程与 Cocoa 的邂逅
onevcat
14
5k
Swift 3 - From Expert to Beginner
onevcat
2
280
如何打造一个让人愉快的框架
onevcat
4
23k
JSPatch Introduction
onevcat
0
230
Objective-C Runtime Swizzle
onevcat
0
240
Unity Memory
onevcat
0
180
Other Decks in Programming
See All in Programming
決定論的オーケストレーションの設計と実装 / Design and Implementation of Deterministic Orchestration
nrslib
3
1.3k
Oxlintのカスタムルールの現況
syumai
6
1.1k
脅威をエンジニアリングの糧にして――現場編 / Turning Threats into Engineering Fuel — Field Edition
nrslib
0
270
The ROI of Quarkus for Spring Boot Applications
hollycummins
0
110
Modding RubyKaigi for Myself
yui_knk
0
920
TAKTでAI駆動開発の品質を設計する
j5ik2o
6
1.2k
Webフレームワークの ベンチマークについて
yusukebe
0
160
Claspは野良GASの夢をみるか
takter00
0
180
依存関係から依存物へ―Dependencyという言葉の歴史をひも解く
j_lee
0
110
Make SRE Operations Easier with Azure SRE Agent
kkamegawa
0
5.3k
JavaDoc 再入門
nagise
0
320
These Five Tricks Can Make Your Apps Greener, Cheaper, & Nicer
hollycummins
0
280
Featured
See All Featured
Writing Fast Ruby
sferik
630
63k
AI Search: Where Are We & What Can We Do About It?
aleyda
0
7.6k
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
エンジニアに許された特別な時間の終わり
watany
107
250k
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
2
570
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
940
brightonSEO & MeasureFest 2025 - Christian Goodrich - Winning strategies for Black Friday CRO & PPC
cargoodrich
3
730
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.5k
Color Theory Basics | Prateek | Gurzu
gurzu
0
360
It's Worth the Effort
3n
188
29k
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
65
55k
Google's AI Overviews - The New Search
badams
0
1k
Transcript
从 Swift 到 机器器学习 CreateML - Swifter 通向 ML 的⾦金金钥匙
王 巍 (onevcat) 2018.09.15, @Swift Conf.
后移动开发时代 Google Trends: “iOS Develop”
WWDC 2013
转变⼀一般都会带来痛苦
如何评价 2017 年年初华为开始「清理理」34 岁以上的职员? 程序员能纯靠技术渡过中年年危机吗? 程序员30岁之前年年薪不不到40W,再不不转⾏行行都晚了了? iOS 末路路了了吗,我找⼯工作两个⽉月,没⼈人要 35 岁做不不到管理理就等于失业
我(们)的出路路在哪⾥里里
我(们)的出路路在哪⾥里里 ⼤大前端 React Native Weex ⼩小程序 Flutter 机器器学习 深度学习 计算机视觉
⾃自然语⾔言处理理 ⻛风格化图像处理理
其余的出路路 区块链 P2P信贷 做个快乐的肥宅
做个快乐的肥宅
I have an idea!
App: 普尔亚后援会 • 使⽤用相机或者照⽚片库 • 识别照⽚片中的普尔亚⼿手势 • 收集到三张照⽚片获得奖励
HOW?
我(们)的出路路在哪⾥里里 ⼤大前端 React Native Weex ⼩小程序 Flutter 机器器学习 深度学习 计算机视觉
⾃自然语⾔言处理理 ⻛风格化图像处理理
CreateML WWDC 2018 Session 703 https://developer.apple.com/videos/play/wwdc2018/703/
⼀一般流程 准备数据 训练模型 评估模型
⼀一般流程 准备数据 训练模型 评估模型 图⽚片 + 分类标签 准备训练数据 (train set)
和验证数据 (validation set) 调整参数 寻找使训练数据具有最⼩小误差值的⼀一组参数 使⽤用验证数据对模型准确率评估
None
⼀一般流程 准备数据 训练模型 评估模型
CreateML 到底做了了什什么
mlmodel https://apple.github.io/coremltools/coremlspecification/index.html Protocol Buffers 序列列化的模型描述 layer 类型,权重等
~KB 迁移学习 VisionFeaturePrint_Scene mlmodel VisionFeaturePrint_Scene 只存在于 iOS 12, macOS 10.14
Vision 框架背后的特征提取 17KB in Demo Transfer Learning
None
✅ VisionFeaturePrint_Scene VisionFeaturePrint_Screen
Core ML Community Tools
None
visionFeaturePrint glmClassifier
开始定义 pipeline 输⼊入 299x299 保留留特性的同时限制处理理时间 内置模型 (特征提取) 2048 个特征的数组 (1,
2048) ⼴广义线性模型 (GLM) (2048, 1),与特征点乘得到结果
发⽣生了了什什么
Turi
Turi • 2013, 成⽴立 • 2016, Apple 以 2 亿美元收购
• 2017, 开源, ⽀支持 Metal 和 macOS GPU 加速 • 2018, 部分集成⼊入 Apple Developer Toolkit (Xcode) • 未来, 更更多的学习任务… 基于学习任务的 “傻⽠瓜式” 机器器学习框架
⼏几个问题
VisionFeaturePrint 集成在 iOS 12 和 macOS 10.14 中 问题 No.1
Core ML - iOS 11 • CoreML 从 iOS 11
开始⽀支持 • ⽆无法读取 CreateML 创建的带有 VisionFeaturePrint 的模型
Core ML - iOS 11 使⽤用 TuriCreate 的其他模型进⾏行行特征提取 可以得到与 CreateML
相近的结果
https://github.com/apple/turicreate
Demo
None
~ 90+ MB
过拟合,准确率 问题 No.2
⼀一个⾼高度 的模型 Overfitting 过拟合
过拟合
过拟合 训练数据严重不不⾜足 只来源于单⼀一⼈人员和单⼀一场景 对于⾮非该⼈人员的识别相当低效 默认的训练⽅方式只对最后⼀一层进⾏行行训练 特征提取模型中不不包含对应特征
0 22.5 45 67.5 90 0 5 10 15 20
准确率
默认特征提取模型下 增加训练数据,可以达到 85% 左右
卷积神经⽹网络和特征提取
抽象特征 (边缘,线条,⻆角度) 具体特征 (眼睛,⿐鼻⼦子,⽿耳朵)
CreateML (Turi) 的迁移学习 只对最后⼀一层进⾏行行训练 抽象特征 泛⽤用性 具体特征 专⽤用性
调整若⼲干层卷积层参数 进⾏行行迁移学习
CreateML / Turi
更更加“可操控”的学习⽅方式
更更加“可操控”的学习⽅方式
92% 左右的正确率
⼀一些客户端 ML 的 实际应⽤用
Super-Resolution SRCNN
https://speakerdeck.com/kenmaz/super-resolution-with-coreml-at-try-swift-tokyo-2018 SRCNNKit from DeNA
https://github.com/DeNA/SRCNNKit
在漫画之外使⽤用 1. 专⻔门的训练数据 2. 通过预处理理提取场景特征 (⼈人物,⻛风景,UI) 3.更更多的层数
⾳音乐情绪识别
从⾳音乐的曲调和节奏识别⾳音乐情绪 Music Keyword 梁梁祝 温柔婉转 命运交响曲 激情雄壮 ⼩小苹果 轻松欢快
其他场景 • 本地垃圾短信识别 • 游戏 AI (GameplayKit) • 专⽤用的图像分类/识别 •
etc…
总结 • ⼩小模型,Client Side ML 的关键 • 对于既有特征表现⾮非常出⾊色 (ImageNet Category)
• 简单,⽆无脑,拖拽式得到可⽤用模型 • 对⼯工程师友好,可以在 client 本机编译 (下载更更新模型)
总结 • 只适⽤用于特定任务 (图⽚片分类/⾃自然语⾔言处理理/回归分析) • TuriCreate 只能有限扩展 (使⽤用第三⽅方模型, ⻛风格化图 ⽚片滤镜等)
• ⽆无法处理理⾃自定义模型,或者更更⼀一般化的任务
⼀一些资源 Awesome Core ML Models https://github.com/likedan/Awesome-CoreML-Models Machine Learning for iOS
https://github.com/alexsosn/iOS_ML Apple Machine Learning Journal https://machinelearning.apple.com Kraggle https://www.kaggle.com Machine Learning (Turi) - Coursera https://coursera.org/specializations/machine-learning Deep Learning with Python https://www.manning.com/books/deep-learning-with-python
谢谢!: ] @onevcat,
[email protected]