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
830
PiPを応用した配信コメントバー機能の開発秘話と技術の詳解 / pip_streaming_comment_bar
narujpn
3
3.8k
Updating an App to Use Swift Concurrency 解説
narujpn
2
290
PiP で実現するミラティブの配信コメントバー / pip-streaming-comment-bar
narujpn
0
1.1k
App Extension のスタックトレース情報からクラッシュを解析/集計する / Analyzing app extension's stack trace
narujpn
3
1.4k
ミラティブとWebRTC - WebRTC framework の中身を覗いてみよう / WebRTC framework AudioUnit Processing
narujpn
1
2.1k
CoreML3のオンデバイストレーニングでつくる母音推定
narujpn
0
400
AltConfと周辺の歩き方
narujpn
0
1.9k
エンジニア経験を活かしたスクラムマスターとして 開発チームとプロダクトを成長させる
narujpn
1
390
Other Decks in Technology
See All in Technology
PL900試験から学ぶ Power Platform 基礎知識講座
kumikeyy
0
110
『衛星データ利用の方々にとって近いようで触れる機会のなさそうな小話 ~ 衛星搭載ソフトウェアと衛星運用ソフトウェア (実物) を動かしながらわいわいする編 ~』 @日本衛星データコミニティ勉強会
meltingrabbit
0
120
プロセス改善による品質向上事例
tomasagi
1
1.6k
30分でわかる『アジャイルデータモデリング』
hanon52_
9
2.2k
Developer Summit 2025 [14-D-1] Yuki Hattori
yuhattor
19
5.1k
開発スピードは上がっている…品質はどうする? スピードと品質を両立させるためのプロダクト開発の進め方とは #DevSumi #DevSumiB / Agile And Quality
nihonbuson
1
1.3k
High Performance PHP
cmuench
0
140
第13回 Data-Centric AI勉強会, 画像認識におけるData-centric AI
ksaito_osx
0
360
明日からできる!技術的負債の返済を加速するための実践ガイド~『ホットペッパービューティー』の事例をもとに~
recruitengineers
PRO
3
100
事業継続を支える自動テストの考え方
tsuemura
0
300
AndroidXR 開発ツールごとの できることできないこと
donabe3
0
110
FastConnect の冗長性
ocise
1
9.6k
Featured
See All Featured
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
175
51k
Bash Introduction
62gerente
610
210k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
7k
Building Better People: How to give real-time feedback that sticks.
wjessup
366
19k
Gamification - CAS2011
davidbonilla
80
5.1k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.1k
Unsuck your backbone
ammeep
669
57k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
20
2.4k
Become a Pro
speakerdeck
PRO
26
5.1k
Fontdeck: Realign not Redesign
paulrobertlloyd
82
5.4k
It's Worth the Effort
3n
184
28k
Writing Fast Ruby
sferik
628
61k
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
͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠