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
990
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
2
570
PiPを応用した配信コメントバー機能の開発秘話と技術の詳解 / pip_streaming_comment_bar
narujpn
3
3.1k
Updating an App to Use Swift Concurrency 解説
narujpn
2
190
PiP で実現するミラティブの配信コメントバー / pip-streaming-comment-bar
narujpn
0
810
App Extension のスタックトレース情報からクラッシュを解析/集計する / Analyzing app extension's stack trace
narujpn
3
1.1k
ミラティブとWebRTC - WebRTC framework の中身を覗いてみよう / WebRTC framework AudioUnit Processing
narujpn
1
1.9k
CoreML3のオンデバイストレーニングでつくる母音推定
narujpn
0
360
AltConfと周辺の歩き方
narujpn
0
1.8k
エンジニア経験を活かしたスクラムマスターとして 開発チームとプロダクトを成長させる
narujpn
1
360
Other Decks in Technology
See All in Technology
ExaDB-D dbaascli で出来ること
oracle4engineer
PRO
0
2.1k
Microsoft Intune 勉強会 第 2 回目
tamaiyutaro
1
250
今日からできる!簡単 .NET 高速化 Tips -2024 edition-
xin9le
5
2.5k
Google Cloud Next '24でブログを10本書いた方法と勉強会を沸かせた方法
yasumuusan
0
310
開発パフォーマンスを最大化するための開発体制
ham0215
2
470
地理空間データ可視化・解析・活用ソリューション Pacific Spatial Solutions (PSS)
pacificspatialsolutions
0
300
Android Target SDK 35 (Android 15) 対応の概要
akkie76
0
120
プラットフォームってつくることより計測することが重要なんじゃないかという話 / Platform Engineering Meetup #8
taishin
1
380
Azure Container Apps + Bicep 〜 こんな感じで運用しています
kaz29
3
570
EM完全に理解した と思ったけど、 やっぱり何も分からなかった話 / EM Night Fukuoka #1
hirutas
0
110
VSCodeの拡張機能を作っている話
ebarakazuhiro
1
660
プロンプトエンジニアリングでがんばらない-Agentic Workflow へ-近藤憲児
kenjikondobai
4
1k
Featured
See All Featured
A designer walks into a library…
pauljervisheath
200
23k
The Invisible Customer
myddelton
114
12k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
14
1.5k
Clear Off the Table
cherdarchuk
84
310k
Building Effective Engineering Teams - LeadDev
addyosmani
28
1.9k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
60
14k
10 Git Anti Patterns You Should be Aware of
lemiorhan
648
58k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
501
140k
Six Lessons from altMBA
skipperchong
21
3k
[RailsConf 2023] Rails as a piece of cake
palkan
23
4k
Build The Right Thing And Hit Your Dates
maggiecrowley
24
2k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
79
43k
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
͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠