Lock in $30 Savings on PRO—Offer Ends Soon! ⏳
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
从 Swift 到机器学习
Search
Wei Wang
September 15, 2018
Programming
2
1k
从 Swift 到机器学习
Wei Wang
September 15, 2018
Tweet
Share
More Decks by Wei Wang
See All by Wei Wang
網路之難,難於上青天 - iPlayground 2019
onevcat
11
5.3k
GMTC 2019 - 在分歧中发展,2019 我们能用 Swift 做什么
onevcat
0
1.2k
iOS Dev - The Dark Side
onevcat
0
150
面向协议编程与 Cocoa 的邂逅
onevcat
14
4.9k
Swift 3 - From Expert to Beginner
onevcat
2
240
如何打造一个让人愉快的框架
onevcat
4
22k
JSPatch Introduction
onevcat
0
210
Objective-C Runtime Swizzle
onevcat
0
220
Unity Memory
onevcat
0
150
Other Decks in Programming
See All in Programming
sbt 2
xuwei_k
0
300
Cell-Based Architecture
larchanjo
0
130
DevFest Android in Korea 2025 - 개발자 커뮤니티를 통해 얻는 가치
wisemuji
0
150
認証・認可の基本を学ぼう後編
kouyuume
0
240
バックエンドエンジニアによる Amebaブログ K8s 基盤への CronJobの導入・運用経験
sunabig
0
160
Python札幌 LT資料
t3tra
3
540
20251212 AI 時代的 Legacy Code 營救術 2025 WebConf
mouson
0
190
宅宅自以為的浪漫:跟 AI 一起為自己辦的研討會寫一個售票系統
eddie
0
510
AIエージェントの設計で注意するべきポイント6選
har1101
5
390
実はマルチモーダルだった。ブラウザの組み込みAI🧠でWebの未来を感じてみよう #jsfes #gemini
n0bisuke2
3
1.2k
AtCoder Conference 2025「LLM時代のAHC」
imjk
2
520
C-Shared Buildで突破するAI Agent バックテストの壁
po3rin
0
390
Featured
See All Featured
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.5k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
231
22k
Designing Experiences People Love
moore
143
24k
Fashionably flexible responsive web design (full day workshop)
malarkey
407
66k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
55
3.1k
Testing 201, or: Great Expectations
jmmastey
46
7.8k
Large-scale JavaScript Application Architecture
addyosmani
515
110k
How Software Deployment tools have changed in the past 20 years
geshan
0
29k
Art, The Web, and Tiny UX
lynnandtonic
304
21k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
10
740
Producing Creativity
orderedlist
PRO
348
40k
Optimizing for Happiness
mojombo
379
70k
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]