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
TFv1.0の概要+HighLevelAPI/Keras
Search
Norihiro Shimoda
March 20, 2017
Technology
4
2.1k
TFv1.0の概要+HighLevelAPI/Keras
Recap of TF Dev Summit(
https://tfug-tokyo.connpass.com/event/52643/
) での発表資料
Norihiro Shimoda
March 20, 2017
Tweet
Share
More Decks by Norihiro Shimoda
See All by Norihiro Shimoda
ぼくのかんがえたさいきょうの機械学習プロジェクト進行法(PoC/デモ編)
rindai87
10
19k
FindYourCandyでの転移学習の話
rindai87
4
15k
Google I/O 報告会(ML)担当
rindai87
3
9.4k
最近のTensorFlowの話
rindai87
1
1.4k
TensorFlowとGCPの簡単な紹介
rindai87
3
4.4k
TensorFlowの基礎
rindai87
2
4.3k
How should engineers survive during AI era
rindai87
5
27k
Let's stand up against "Do Artificial Intelligence" with proper knowledge
rindai87
6
1.8k
Talk about ML and DL for happy engineer's life
rindai87
40
15k
Other Decks in Technology
See All in Technology
信頼されるためにやったこと、 やらなかったこと。/What we did to be trusted, What we did not do.
bitkey
PRO
0
1.2k
プロダクト組織で取り組むアドベントカレンダー/Advent Calendar in Product Teams
mixplace
0
650
Fearsome File Formats
ange
0
550
サイバー攻撃を想定したセキュリティガイドライン 策定とASM及びCNAPPの活用方法
syoshie
3
1.7k
アジャイルチームが変化し続けるための組織文化とマネジメント・アプローチ / Agile management that enables ever-changing teams
kakehashi
2
1.9k
10年もののバグを退治した話
n_seki
0
140
Formal Development of Operating Systems in Rust
riru
1
350
生成AIによるテスト設計支援プロセスの構築とプロセス内のボトルネック解消の取り組み / 20241220 Suguru Ishii
shift_evolve
0
160
20241228 - 成為最強魔法使!AI 實時生成比賽的策略 @ 2024 SD AI 年會
dpys
0
330
サイボウズフロントエンドエキスパートチームについて / FrontendExpert Team
cybozuinsideout
PRO
5
39k
20241220_S3 tablesの使い方を検証してみた
handy
4
860
能動的ドメイン名ライフサイクル管理のすゝめ / Practice on Active Domain Name Lifecycle Management
nttcom
0
310
Featured
See All Featured
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5.1k
Designing for humans not robots
tammielis
250
25k
Embracing the Ebb and Flow
colly
84
4.5k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
27
1.5k
Measuring & Analyzing Core Web Vitals
bluesmoon
5
190
Rails Girls Zürich Keynote
gr2m
94
13k
Faster Mobile Websites
deanohume
305
30k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
232
17k
Building Your Own Lightsaber
phodgson
104
6.1k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
A Tale of Four Properties
chriscoyier
157
23k
Statistics for Hackers
jakevdp
796
220k
Transcript
Overview of TF v1.0 + High Level API / Keras
Norihiro Shimoda
⾃自⼰己紹介 • Norihiro Shimoda(@rindai87) • TensorFlow User Group(TFUG)主催者 • 最近GDE(Google
Developer Expert)の ML Expertになりました
Agenda • TensorFlowの概要 • TensorFlow v1.0の概要 • High Level API
/ Keras
TensorFlowの概要
TensorFlowとは? • Googleがオープンソース化した機械学習 のライブラリ • 2015年年11⽉月に公開 • Google社内でも実際に使われている(と ⾔言われている)
TensorFlowのモデル 1. 学習モデルをグラフとし て定義する 2. 学習を実際にどう⾏行行うか も定義する – 学習の評価⽅方法 –
最適化の⽅方法 – CPU or GPU – スタンドアロン or 分散 3. 定義に従って計算処理理を デバイス上で実⾏行行させる
TensorFlowの歴史
TensorBoardなどのツール
その他のTensorFlow情報 1. Google内でのTensorFlow 2. TensorFlowの事例例 3. TensorFlowコミュニティ 4. 企業でのTensorFlow
TensorFlow v1.0の概要
V1.0を三⾏行行でまとめると… Fast Flexible Production-‐‑‒ready
三⾏行行まとめをもう少し詳しく • Fast – めっちゃパフォーマンス良良くなりました • Flexible – ⾼高レベルAPIが本格的に導⼊入されました •
Production-‐‑‒ready – APIは安定させます • その他もいろいろあります – デバッガ(tfdbg)、多⾔言語対応など
Fast • パフォーマンスの⼤大幅な向上 – 64GPU上でのInception v3の処理理が58倍⾼高 速になった! • XLAの導⼊入 –
Accelerated Linear Algebraの略略 – コンパイラ – この後のセッションで詳細を話します https://developers-‐‑‒jp.googleblog.com/2017/03/xla-‐‑‒tensorflow-‐‑‒compiled.html
Flexible • High Level APIの本格的な導⼊入 – この後詳細をお話します • Kerasとの統合 –
割と個⼈人的にはビッグニュース
Production Ready • APIの安定化 – V0.11, v0.12辺りの混乱が収束するはずJ – が、後⽅方互換性崩れてますL –
が、移⾏行行ツールが提供されていますJ https://github.com/tensorflow/tensorflow/tree/master/tensorflow/tools/compatibility
その他 • デバッガ(tfdbg) – 待望のデバッグツール – まだちゃんと触れていませんが期待⼤大 • 多⾔言語対応 –
JavaとGoがExperimentalながら対応
High Level API / Keras
TensorFlowの超基本 1. ⼊入⼒力力⽤用にplaceholderを⽤用意 2. 重みやバイアス⽤用にVariableを⽤用意 3. 活性化関数を使って層を定義 4. ロス値を定義 5.
最適化の⽅方法を定義 6. セッションを定義して学習を実⾏行行
この後のサンプルコード • わかりやすくDNN – 隠れ層3層で全て全結合層 – ユニット数は10,20,10 • サンプルデータとしてはirisデータ –
クラス数は3 – 特徴量量の次元数は4 • サンプルコード⾃自体はQiitaで解説付きで 公開しています http://qiita.com/rindai87/items/72651c702e9265595047
None
None
⽣生TensorFlow⾟辛い問題 • APIがけっこう低レベルなため、アルゴリ ズム構築に集中したい⼈人には⾮非常に敷居 が⾼高い – TensorFlowのパラダイムへの理理解が必須 – そのため、学習コストが⾼高い •
PlaceholderとかVariableとかSessionとか
従来の⽣生TF⾟辛い問題の解決法 • tf.contrib.learn – ⾼高レベルなAPI • Keras – TensorFlowのラッパー –
作者がGoogleの中の⼈人 • その他いろいろ – SlimとかTFLearnとか
tf.contrib.learn • V1.0以前から導⼊入されていた⾼高レベルAPI – 今も残っていて現役で使える • もともとはSkFlowという外部ライブラリ – scikit-‐‑‒learnライクにTF使いましょう、という コンセプト
• V0.8からTF本体に取り込まれて TFLearn(tf.contrib.learn)となる
None
Keras • TensorFlowとTheanoのラッパーライブ ラリ • ネットワークを直感的に記述できる – ⽣生TFのようにTensorFlowの流流儀を覚える必 要がない •
アルゴリズム側に集中したい⼈人にとって は良良い選択肢 • 全機能がラップされているわけではない
None
V1.0で⾊色々整理理されはじめます • V1.0で混沌としていた⾼高レベルAPI周りの 整理理とロードマップの提⽰示が⾏行行われまし た – Layers – Estimator •
Kerasを正式にサポート – そもそもKerasの中の⼈人はGoogler
None
Layers • モデル(ネットワーク)を定義するため のAPI群 • Kerasのように直感的にモデルを記述して いくことができる • Variableの概念念は登場しない –
Layersのオブジェクトを直接触ることも可能 なので、その場合はPlaceholderは登場する
Layersのイメージ Input (4dim) hidden1 hidden2 hidden3 Output (3classes) IrisデータをDNNでモデルを 作る簡単な例例で⾒見見てみる
・4次元データ ・クラスは3 ・隠れ層は3層
Layersのイメージ input hidden1 hidden2 hidden3 output input_̲layer=tf.reshape(features, [-‐‑‒1, 4])
Layersのイメージ input hidden1 hidden2 hidden3 output hidden1=tf.layers.dense( inputs=input_̲layers, units=10,
activation=tf.nn.relu) input_̲layer=tf.reshape(features, [-‐‑‒1, 4])
Layersのイメージ input hidden1 hidden2 hidden3 output hidden1=tf.layers.dense( inputs=input_̲layers, units=10,
activation=tf.nn.relu) input_̲layer=tf.reshape(features, [-‐‑‒1, 4]) hidden2=tf.layers.dense(…) hidden3=tf.layers.dense(…)
Layersのイメージ input hidden1 hidden2 hidden3 output hidden1=tf.layers.dense( inputs=input_̲layers, units=10,
activation=tf.nn.relu) input_̲layer=tf.reshape(features, [-‐‑‒1, 4]) output_̲layer=tf.layers.dense( inputs=hidden3, units=3) hidden2=tf.layers.dense(…) hidden3=tf.layers.dense(…)
Estimator • モデルを使った学習、評価、推論論のタス クを記述するための標準的なインター フェイスを提供するAPI群 • Scikit-‐‑‒learn経験者にはおなじみにイン ターフェース+α – fit():学習
– evaluate():評価 – predict():推論論 – etc…
Estimatorのイメージ input Model output 実際はこれだけではなくて
Estimatorのイメージ input Model Training 記述したモデルを使って 学習、(学習モデルの)評価、推定を⾏行行う Evaluation Prediction
Estimatorのイメージ input Model Training 学習、評価、推定に関わるタスクは全てEstimator内に 隠蔽して標準的なインターフェースを提供 TensorFlowの種々の概念念もEstimator内に内包 Evaluation Prediction fit()
evaluate() predict() session graph etc… Estimator
Canned Estimator • Layers, Estimatorのお陰で、モデルに対 して標準的なインターフェースが提供さ れている状態になる • これを利利⽤用して、様々なEstimator(つま りアルゴリズム)を提供していく
– インターフェースが共通化されているので、 同⼀一データに対して様々なアルゴリズムを簡 単に試せるようになる • おっとこれはscikit-‐‑‒learnな感じですね、 と思ったあなた、正解です
Kerasの正式サポート • LayersをKerasの層を定義するレイヤー (Denseなど)と互換性のあるものとする • EstimatorとKerasでの互換性を担保する 設計 • これまで通りTFをラップしたKeras •
tf.kerasの導⼊入により、TF内部でkerasのコードが 動くようになる?
Keras正式サポートの恩恵 • 今までKerasから使えていなかった各種TFの 機能が使えるようになる – 分散処理理による学習 – CloudMLでの実⾏行行 • これまではCloudMLのプロビジョニングの段階でKeras
をpip installするというハックで解決していた • なお、この解決⽅方法を使ってもKerasからはGCSに置い ているデータを読みにいけないという問題が残っている – TensorFlow Serving – etc…
None
Thank you!!