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.5k
最近のTensorFlowの話
rindai87
1
1.5k
TensorFlowとGCPの簡単な紹介
rindai87
3
4.6k
TensorFlowの基礎
rindai87
2
4.4k
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
新規プロダクトでプロトタイプから正式リリースまでNext.jsで開発したリアル
kawanoriku0
1
120
「何となくテストする」を卒業するためにプロダクトが動く仕組みを理解しよう
kawabeaver
0
420
Modern Linux
oracle4engineer
PRO
0
100
Language Update: Java
skrb
2
300
TS-S205_昨年対比2倍以上の機能追加を実現するデータ基盤プロジェクトでのAI活用について
kaz3284
1
170
250905 大吉祥寺.pm 2025 前夜祭 「プログラミングに出会って20年、『今』が1番楽しい」
msykd
PRO
1
950
Android Audio: Beyond Winning On It
atsushieno
0
870
react-callを使ってダイヤログをいろんなとこで再利用しよう!
shinaps
1
250
CDK CLIで使ってたあの機能、CDK Toolkit Libraryではどうやるの?
smt7174
4
190
大「個人開発サービス」時代に僕たちはどう生きるか
sotarok
20
10k
共有と分離 - Compose Multiplatform "本番導入" の設計指針
error96num
2
580
現場で効くClaude Code ─ 最新動向と企業導入
takaakikakei
1
250
Featured
See All Featured
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
18
1.1k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
26
3k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
51
5.6k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
126
53k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
Making the Leap to Tech Lead
cromwellryan
135
9.5k
Reflections from 52 weeks, 52 projects
jeffersonlam
352
21k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
61k
Embracing the Ebb and Flow
colly
87
4.8k
It's Worth the Effort
3n
187
28k
How STYLIGHT went responsive
nonsquared
100
5.8k
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!!