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.4k
TensorFlowとGCPの簡単な紹介
rindai87
3
4.5k
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
クラウド開発環境Cloud Workstationsの紹介
yunosukey
0
180
Ops-JAWS_Organizations小ネタ3選.pdf
chunkof
2
170
C++26アップデート 2025-03
faithandbrave
0
600
品質文化を支える小さいクロスファンクショナルなチーム / Cross-functional teams fostering quality culture
toma_sm
0
120
MCPを活用した検索システムの作り方/How to implement search systems with MCP #catalks
quiver
12
6.8k
新卒エンジニアがCICDをモダナイズしてみた話
akashi_sn
2
250
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
0
110
生成AIによるCloud Native基盤構築の可能性と実践的ガードレールの敷設について
nwiizo
7
980
勝手に!深堀り!Cloud Run worker pools / Deep dive Cloud Run worker pools
iselegant
2
430
Стильный код: натуральный поиск редких атрибутов по картинке. Юлия Антохина, Data Scientist, Lamoda Tech
lamodatech
0
740
サーバレス、コンテナ、データベース特化型機能をご紹介。CloudWatch をもっと使いこなそう!
o11yfes2023
0
180
ガバクラのAWS長期継続割引 ~次の4/1に慌てないために~
hamijay_cloud
1
260
Featured
See All Featured
Optimising Largest Contentful Paint
csswizardry
36
3.2k
Bootstrapping a Software Product
garrettdimon
PRO
307
110k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
129
19k
How to train your dragon (web standard)
notwaldorf
90
6k
Scaling GitHub
holman
459
140k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.4k
Building an army of robots
kneath
304
45k
The Power of CSS Pseudo Elements
geoffreycrofte
75
5.8k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
178
53k
Fireside Chat
paigeccino
37
3.4k
VelocityConf: Rendering Performance Case Studies
addyosmani
328
24k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
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!!