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
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Wei Wang
September 15, 2018
Programming
2
1.1k
从 Swift 到机器学习
Wei Wang
September 15, 2018
Tweet
Share
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
160
面向协议编程与 Cocoa 的邂逅
onevcat
14
5k
Swift 3 - From Expert to Beginner
onevcat
2
260
如何打造一个让人愉快的框架
onevcat
4
22k
JSPatch Introduction
onevcat
0
220
Objective-C Runtime Swizzle
onevcat
0
230
Unity Memory
onevcat
0
160
Other Decks in Programming
See All in Programming
CSC307 Lecture 15
javiergs
PRO
0
210
AI時代でも変わらない技術コミュニティの力~10年続く“ゆるい”つながりが生み出す価値
n_takehata
2
610
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
380
atmaCup #23でAIコーディングを活用した話
ml_bear
4
730
Go1.26 go fixをプロダクトに適用して困ったこと
kurakura0916
0
320
文字コードの話
qnighy
43
17k
nuget-server - あなたが必要だったNuGetサーバー
kekyo
PRO
0
140
Claude Codeと2つの巻き戻し戦略 / Two Rewind Strategies with Claude Code
fruitriin
0
200
今、アーキテクトとして 品質保証にどう関わるか
nealle
0
200
RAGでハマりがちな"Excelの罠"を、データの構造化で突破する
harumiweb
9
2.4k
守る「だけ」の優しいEMを抜けて、 事業とチームを両方見る視点を身につけた話
maroon8021
3
210
DSPy入門 Pythonで実現する自動プロンプト最適化 〜人手によるプロンプト調整からの卒業〜
seaturt1e
1
480
Featured
See All Featured
Scaling GitHub
holman
464
140k
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.2k
Test your architecture with Archunit
thirion
1
2.2k
Build your cross-platform service in a week with App Engine
jlugia
234
18k
Agile that works and the tools we love
rasmusluckow
331
21k
The World Runs on Bad Software
bkeepers
PRO
72
12k
Bash Introduction
62gerente
615
210k
The agentic SEO stack - context over prompts
schlessera
0
680
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
360
How STYLIGHT went responsive
nonsquared
100
6k
Git: the NoSQL Database
bkeepers
PRO
432
66k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
49
9.9k
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]