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
CoreMLではじめる機械学習
Search
naru-jpn
June 21, 2017
Technology
0
1.1k
CoreMLではじめる機械学習
Neural Networks on Keras ( TensorFlow backends )
naru-jpn
June 21, 2017
Tweet
Share
More Decks by naru-jpn
See All by naru-jpn
配信アプリのためのリアルタイムプッシュ通知ぼかしの夢
narujpn
3
760
PiPを応用した配信コメントバー機能の開発秘話と技術の詳解 / pip_streaming_comment_bar
narujpn
3
3.6k
Updating an App to Use Swift Concurrency 解説
narujpn
2
250
PiP で実現するミラティブの配信コメントバー / pip-streaming-comment-bar
narujpn
0
980
App Extension のスタックトレース情報からクラッシュを解析/集計する / Analyzing app extension's stack trace
narujpn
3
1.3k
ミラティブとWebRTC - WebRTC framework の中身を覗いてみよう / WebRTC framework AudioUnit Processing
narujpn
1
2k
CoreML3のオンデバイストレーニングでつくる母音推定
narujpn
0
390
AltConfと周辺の歩き方
narujpn
0
1.9k
エンジニア経験を活かしたスクラムマスターとして 開発チームとプロダクトを成長させる
narujpn
1
370
Other Decks in Technology
See All in Technology
Why does continuous profiling matter to developers? #appdevelopercon
salaboy
0
190
データプロダクトの定義からはじめる、データコントラクト駆動なデータ基盤
chanyou0311
2
300
フルカイテン株式会社 採用資料
fullkaiten
0
40k
Why App Signing Matters for Your Android Apps - Android Bangkok Conference 2024
akexorcist
0
120
強いチームと開発生産性
onk
PRO
34
11k
OCI Security サービス 概要
oracle4engineer
PRO
0
6.5k
Exadata Database Service on Dedicated Infrastructure(ExaDB-D) UI スクリーン・キャプチャ集
oracle4engineer
PRO
2
3.2k
安心してください、日本語使えますよ―Ubuntu日本語Remix提供休止に寄せて― 2024-11-17
nobutomurata
1
990
TanStack Routerに移行するのかい しないのかい、どっちなんだい! / Are you going to migrate to TanStack Router or not? Which one is it?
kaminashi
0
580
AWS Media Services 最新サービスアップデート 2024
eijikominami
0
200
Engineer Career Talk
lycorp_recruit_jp
0
150
マルチプロダクトな開発組織で 「開発生産性」に向き合うために試みたこと / Improving Multi-Product Dev Productivity
sugamasao
1
300
Featured
See All Featured
Put a Button on it: Removing Barriers to Going Fast.
kastner
59
3.5k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
27
840
Facilitating Awesome Meetings
lara
50
6.1k
Building Better People: How to give real-time feedback that sticks.
wjessup
364
19k
Imperfection Machines: The Place of Print at Facebook
scottboms
265
13k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
47
2.1k
Gamification - CAS2011
davidbonilla
80
5k
Reflections from 52 weeks, 52 projects
jeffersonlam
346
20k
Rebuilding a faster, lazier Slack
samanthasiow
79
8.7k
Code Reviewing Like a Champion
maltzj
520
39k
A Philosophy of Restraint
colly
203
16k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
6
410
Transcript
CoreMLͰ͡ΊΔػցֶश Neural Networks on Keras ( TensorFlow backends ) Timers
inc. / Github: naru-jpn / Twitter: @naruchigi
CoreMLͰ͡ΊΔػցֶश Timers inc. / Github: naru-jpn / Twitter: @naruchigi Neural
Networks on Keras ( TensorFlow backends )
What is Neural Networks?
One of machine learning models. - Neural networks - Tree
ensembles - Support vector machines - Generalized linear models - … https://developer.apple.com/documentation/coreml/converting_trained_models_to_core_ml
What is Keras?
Theano TensorFlow Keras Keras is a high-level neural networks API,
written in Python and capable of running on top of either TensorFlow, CNTK or Theano. https://keras.io
What is CoreML?
Accelerate and BNNS Metal Performance Shaders CoreML BNNS : Basic
Neural Network Subroutines https://developer.apple.com/documentation/coreml With Core ML, you can integrate trained machine learning models into your app. Core ML requires the Core ML model format.
CoreML Trained Model Application Keras Train coremltools
What is coremltools?
Convert existing models to .mlmodel format from popular machine learning
tools including Keras, Caffe, scikit-learn, libsvm, and XGBoost. https://pypi.python.org/pypi/coremltools coremltools
CoreML Trained Model Application Keras Train coremltools
(Demo App)
Environment - Tensorflow 1.1.0 (virtualenv) - Keras 1.2.2 - coremltools
0.3.0 - Xcode 9.0 beta ※ Tensorflow, Keras coremltools ͷରԠόʔδϣϯͰ͋Δඞཁ͕͋ΔͷͰগ͠ݹ͍Ͱ͢ɻ
Programs to train neural networks - mnist_mlp.py - mnist_cnn.py ※
Keras ͷ࠷৽όʔδϣϯͷϦϯΫʹͳ͍ͬͯ·͕͢ɺ࣮ࡍόʔδϣϯ 1.2.2 Λࢀর͠·͢ɻ https://github.com/fchollet/keras/tree/master/examples
Convert model with coremltools 1. Import coremltools import coremltools model
= Sequential() … coreml_model = coremltools.converters.keras.convert(model) coreml_model.save("keras_mnist_mlp.mlmodel") 2. Convert model
Import model into Xcode project // 入力データ class keras_mnist_mlpInput :
MLFeatureProvider { var input1: MLMultiArray // … } // 出力データ class keras_mnist_mlpOutput : MLFeatureProvider { var output1: MLMultiArray // … } // モデル @objc class keras_mnist_mlp:NSObject { var model: MLModel init(contentsOf url: URL) throws { self.model = try MLModel(contentsOf: url) } // … func prediction(input: keras_mnist_mlpInput) throws -> keras_mnist_mlpOutput { // … keras_mnist_mlp.mlmodel Λѻ͏ҝͷίʔυ͕ࣗಈੜ͞ΕΔ
Prepare model and input in code // モデルの作成 let model
= keras_mnist_mlp() // 入力データの格納用変数 (入力は28*28の画像) let input = keras_mnist_mlpInput( input1: try! MLMultiArray(shape: [784], dataType: .double) )
Modify input value // 入力データの 0 番目の要素に 1.0 を代入 input.input1[0]
= NSNumber(value: 1.0)
Make a prediction // モデルに入力データを渡して計算 let output = try model.prediction(
input: self.input )
CoreML Trained Model Application Keras Train coremltools Recap
Demo App on Github https://github.com/naru-jpn/MLModelSample
͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠