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
React ABC Questions
hirotomoyamada
0
560
AIエージェント開発手法と業務導入のプラクティス
ykosaka
9
2.3k
SnowflakeとDatabricks両方でRAGを構築してみた
kameitomohiro
1
490
クラウド開発環境Cloud Workstationsの紹介
yunosukey
0
200
AWSのマルチアカウント管理 ベストプラクティス最新版 2025 / Multi-Account management on AWS best practice 2025
ohmura
4
340
日経電子版 for Android の技術的課題と取り組み(令和最新版)/android-20250423
nikkei_engineer_recruiting
1
500
30代からでも遅くない! 内製開発の世界に飛び込み、最前線で戦うLLMアプリ開発エンジニアになろう
minorun365
PRO
15
4.6k
Goの組織でバックエンドTypeScriptを採用してどうだったか / How was adopting backend TypeScript in a Golang company
kaminashi
12
8.8k
CodePipelineのアクション統合から学ぶAWS CDKの抽象化技術 / codepipeline-actions-cdk-abstraction
gotok365
5
310
読んで学ぶ Amplify Gen2 / Amplify と CDK の関係を紐解く #jawsug_tokyo
tacck
PRO
1
260
営業向け誰でも話せるOCIセールストーク
oracle4engineer
PRO
2
100
Classmethod AI Talks(CATs) #21 司会進行スライド(2025.04.17) / classmethod-ai-talks-aka-cats_moderator-slides_vol21_2025-04-17
shinyaa31
0
630
Featured
See All Featured
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
331
21k
Speed Design
sergeychernyshev
29
910
Raft: Consensus for Rubyists
vanstee
137
6.9k
jQuery: Nuts, Bolts and Bling
dougneiner
63
7.7k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
248
1.3M
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
5
540
4 Signs Your Business is Dying
shpigford
183
22k
Documentation Writing (for coders)
carmenintech
69
4.7k
Reflections from 52 weeks, 52 projects
jeffersonlam
349
20k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
29
9.4k
Docker and Python
trallard
44
3.3k
Automating Front-end Workflow
addyosmani
1370
200k
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!!