字幕表 動画を再生する
[MUSIC PLAYING]
TensorFlow 2エンジニアリーダーの マーティン・ウィケです
MARTIN WICKE: I'm Martin Wicke.
当たり前ですが これから
I'm the engineer lead for a TensorFlow 2,
TensorFlow 2についてお話しします
and I am going to, unsurprisingly, talk
TensorFlowは 非常に成功しています
about TensorFlow 2.
スタート時には 想像できなかったですが
TensorFlow has been extremely successful.
Google内でも Google外でも
And inside of Google, outside of Google,
活気のあるコミュニティに育ちました
it has grown into a vibrant community
ユーザーたちは 毎日 芸術と音楽からも
that really when we started it we were not able to imagine.
初耳ですが中世の手書き写本からも 科学や医学からも
And our users are building these ingenious, clever, elegant
巧妙で賢くエレガントなものを
things everyday from art and music,
ビルドしています
from what you just heard about medieval manuscripts, science,
みなさんが作成したものは 予想以上に美しくて
and medicine.
我々は そこから 多くのことを学びました
And the things people created were unexpected and beautiful.
みなさんの作成方法から 多くのことを学びました
And we learned a lot from that.
TensorFlowは これらすべての 創造性を可能にしていて
And we learned a lot from how people did it.
本当にAIの完全民主化を可能にしました
And TensorFlow flow has enabled all this creativity
最高ですね
and really jumpstarted this whole AI democratization,
しかし 時折 使いづらいですよね?
which is great.
時折 苦痛を伴います
But it has been a little bit hard to use sometimes
標準Pythonから移行しているときに セッションを使う実行には
And we know.
違和感がありました
At sometimes it's been a little painful.
TensorFlowのAPIは 時間と共に成長し
So using sessions wasn't the most natural thing
少し複雑で紛らわしくなりました
to do when coming from regular Python.
最終的にはTensorFlowを使えば 何でもできますが
And the TensorFlow API has grown over time
TensorFlowを使うのが 最善であると
and got a little bit cluttered, a little bit confusing.
言えないときもあります
In the end, you can do everything with TensorFlow,
ですから TensorFlowを始めてから 我々は多くのことを学び
but it wasn't always clear what's the best
ラピッドプロトタイピングや より容易なデバッグが必要であること
way to do it with TensorFlow.
ひどく煩雑であることを 認識したのです
And so we've learned a lot since we started this,
ですから それを改善し
and we realized that you need rapid prototyping,
新バージョンのTensorFlowで それらの問題に取り組んでいます
you need easier debugging, there's a lot of clutter.
今は TensorFlow 2 アルファ版がリリースされています
So we're fixing this.
我々が実装した全機能に アクセスする設計レビューに
We're addressing these issues with a new version
多くの人が 参加してくれました
of TensorFlow--
血のにじむような開発と 隣り合わせの生活に参加した人たちは
today, releasing an alpha of TensorFlow 2.
毎晩プレイしてくれたのでしょう
Many of you have participated in the design reviews
インストールして 試して
that went into this for all the features
問題を発見し 改善してくれました
that we have implemented.
ご協力に とても感謝しています
Those of you who are really living
現在 TensorFlow 2アルファ版は 前のTensorFlowや
on the bleeding edge of development
pipインストールを使用した インストールが可能です
have probably played with a nightly.
それだけで使用開始できます
You have installed it.
では 何が変わったのでしょうか?
You have tested it.
我々が TensorFlow 2を作るときの 最大の焦点は
You have found issues.
ユーザビリティでした
You have fixed issues.
TensorFlowの高レベルAPIとして Kerasを採用しました
So thank you very much for your help.
TensorFlowとKerasを 深く統合しました
You can now install the alpha release of TensorFlow 2
Kerasはモデルの開発と展開における クリアな方法を与えてくれます
using just pip install --pre tenserflow.
このAPIで生産性が上がり
And you can go and play with it.
使用を開始しやすいのです
So what has changed?
もちろん TensorFlowにも Kerasの完全な実装が入っています
When we create TensorFlow 2, really the biggest focus
でも さらに推し進め
is on usability.
Kerasを拡張したので
We've adopted Keras as the high level API for TensorFlow.
TensorFlow内の すべてのアドバンス機能が
We've integrated it very deeply with TensorFlow.
直接 tf.kerasから使用できます
Keras gives you a clear path of how to develop models,
他に変わったことは
how to deployment models.
Eager Executionが デフォルトになったことです
It has a [INAUDIBLE] API that makes people productive,
古いTensorFlow 1.xバージョンは 宣言型を使用しており
and we know that it gets you started quickly.
それがPythonのものと 一致しないことが多々ありました
TensorFlow also includes a complete implementation
TensorFlow 2では サラウンドコードと一致して動作します
of Keras, of course.
ですから 2つの数字を合計すれば 即時に結果が返ってきます
But we went further.
本当に素晴らしいですね
We have extended Keras so that you
なので...
can use all of the advanced features in TensorFlow
ですからグラフを作成するのにも
directly from tf.keras.
広大なプログラムをシリアル化するのにも
The other big change in TensorFlow 2
プログラムを簡単に配信するのにも
is that it is Eager execution by default. Traditional 1.x
分散コンピューティングするのにも
TensorFlow used a declarative style,
グラフに最適化させるにも 利便性が付与されます
and it was often a little bit dissonant with the surrounding
それらの機能は難しくなく 簡単なものです
Python.
TensorFlow 2は メジャーリリースです
And in TensorFlow 2, TensorFlow behaves just
つまり 我々に クリーンアップができるのです
like the surrounding code.
これまで多くのことをしました
So if you add up two numbers, you
数多くの重複した機能を消去し
get a result back immediately, which is amazing, really.
APIを連結したり 整理したり
[LAUGHTER]
APIのイメージを 首尾一貫したものにしたり
But you still get all the benefits
それは TensorFlowだけでなく
of working with A graph--
TensorFlowの周辺で成長してきた ツールエコシステム全体です
robust program serializating, easy distribution
すべてのインターフェースを 試したり 並べるのに
of programs, distributed computation,
多大な努力を費やしました
optimizations on the graph.
そして そのエコシステムのどこへでも スムーズに移動できる
All of that stuff is not going away, it's just getting easier.
交換フォーマットを明確にしました
So TensorFlow 2 is a major release,
多くのものが TensorFlowから取り除かれましたが
which means that we have the ability to clean it up.
それは 機能が減ったのではなく
And we did-- like, a lot.
より柔軟になったのです
So we had a lot of duplicate functionality
柔軟性を保ち 拡張することで
that we have removed.
このような開発のすべてが 可能になったのです
We've consolidated the API.
現在 内部で使用するOPSをすべて robモジュール経由でユーザーに公開する
We've organized the API.
より完成された低レベルAPIを 我々は 作成しました
We've made sure that the API looks and feels consistent.
変数やチェックポイントなど TensorFlow内の重大コンセプト用の
And this is not only about TensorFlow itself,
継承可能インターフェースを すべて提供しています
this is about the whole ecosystem of tools that
これにより フレームワークの作者は
has grown around TensorFlow.
残りのエコシステムとの 相互運用性を維持しながらも
We've spent a lot of effort to try and align
TensorFlowのトップに ビルドできるのです
all of these interfaces.
たくさんの使用例は 後々 出てくると思います
And we've defined exchange formats
TensorFlowエージェントの講演も 本日 この後でありますし
that'll allow you to move all throughout this ecosystem
DeepMindによるSonnetについての 講演も 明日ありますので
without hitting any barriers.
実践的な使用方法については そちらでどうぞ
We have removed a lot of stuff from TensorFlow,
では みなさんに 質問させてください
but that doesn't mean that it's not--
私は 素晴らしい 新時代TensorFlowの一部として
it has gotten more flexible, not less.
何をすべきでしょうか?
It retains and expands on the flexibility
いつだって 何かに アップグレードするのは大変です
we had that enabled all of this development.
メジャーバージョンの アップグレードは 特にそうです
And we've created a more complete low level
Googleは これから TensorFlow 2への
API that now exposes all of the internally use ops
世界最大のコードベース 変換処理を開始します
to the users via the robs module.
我々は その変換処理をしつつ 移行ガイドの記載も行います
We provide inheritable interfaces
すでに開始され オンライン公開されたものもあります
for all of the crucial concepts in TensorFlow,
多数の最適な実践が 提供されることになるでしょう
like variables and checkpoints.
Googleでできることは みなさんにもできます
And this allows framework authors
その移行をスムーズにするための
to build on top of TensorFlow while maintaining
ツールが 数多く提供されています
interoperability with the rest of the ecosystem.
まずは TensorFlow 2の一部として
And you'll hear a lot of these examples later.
互換モジュールである tf.compat.v1が出ています
There'll be talk about TF agents later today.
これには1.xバージョンの すべてのAPIが入っています
There'll be a talk about Sonnet by DeepMind tomorrow.
ですので 特定の機能が 廃止予定だとしても
So you'll see examples of how this works in practice.
その機能を使い続けたり 検索することもできます
Now, the real question for you is, of course, what
しかし tf.contribは含まれませんので
do I have to do to be a part of this great new era
除外してください
of TensorFlow?
しかし 代わりに コミュニティサポートを設置しました
And we know it's always hard to upgrade to anything.
そこを頼っていただければ 使用方法をサポートします
And that's especially true for major version upgrades.
TensorFlow 2で走るコードを
At Google, we will now start the process
自動的にアップデートする スクリプトも発表していますので
of converting one of the largest codebases in the world
その動作をお見せしましょう
to TensorFlow 2.
このプログラムを変換するとします
And while we're doing that, we'll
これはShakespeareにより洗練された 簡単な言語モデルでオンライン存在する
be writing a lot of migration guides.
シンプルな例です
we have started that already, and some of them
ここに TensorFlow 2すべてに インストールされるユーティリティの
are online and will provide a lot of best practices for you.
tf_upgrade_v2を走らせるだけです
And if we can do it at Google, you can probably do it too.
これは 実行したことを表示します
So we're giving you and us a lot of tools
この場合 数か所が変更されました
to make this transition easier.
そして 変更部分を見ると
And first of all, as part of TensorFlow 2,
いくつか改名された機能があります
we're shipping a compatibility module--
APIが認識されると 機能の改名が起こります
we call it tf.compat.v1--
つまり multinomialは 実は機能として間違った名前なんです
which contains all of the 1.x API.
なので random.categorical.に 改名されました
So if you rely on a specific deprecated function,
スクリプトが表示されるので 心配ありませんね
you can still use it, and you can still find it there,
機能の改名や命令の変更において 多くの議論がされました
except for t tf.contrib, which is not
追加や削除についても 議論されました
going to be included at all.
みなさんのために できるだけ スクリプトによる変更をしています
But we've created a community-supported alternative
そして それでもダメなら
that support your use case if you rely on something in there.
TensorFlow 1に存在した符号と
We're also publishing a script which will automatically
TensorFlow 2のものが 完璧に同じではないので
update your code so it runs on TensorFlow 2.
先ほどの互換性モジュールを使います
Let me show you how that works.
完全に置換したものがないなら
Let's say I want to convert this program, which
変換後もコードが 期待通りに動作するかを
is a simple example that we have online of a simple language
確認するために 使用します
model trained on Shakespeare.
旧時代的ですね
So what I do is I simply run tf_upgrade_v2,
例えば AdamOptimizeは
which is a utility that's included with any installation
大部分で動作が 微妙に変わっていますが
of TensorFlow 2.
影響はないでしょう
It tells me what it did.
しかし 万が一のため
And in this case, there's really just a handful of things
compat.v1 AdamOptimizerに 変換します
that it changed.
一度 変換が完了して エラーが なかったら
And you can see, if you look at what changed,
TensorFlow 2で 新プログラムを走らせても
there's some functions that it renamed.
動作するでしょう
The reorganization of the API leads to renamed functions.
以上です
So multinomial was actually the wrong name for this function.
とても簡単ですよね
So it renamed it to random.categorical.
トラブルがないことを祈ります
That's something the script will do for you,
この自動変換は 変更して動作するものですが
so you don't have to worry too much about it.
スタイル自体をTensorFlow 2に 変更しないので 覚えていてください
A lot of functions had arguments renamed, their order changed,
それは自動ではありません
or some arguments added or deleted.
処理について学ぶことは たくさんありますので
As far as possible, the script will make those changes
もっと知りたい方は 明日10時半からのアンナとトーマの
for you.
2.0と移植の例についての講演を 確認してください
And then, if all else fails, sometimes there
行く価値があります
isn't really a perfect equivalent in TensorFlow 2
もちろん 我々もGoogle で その処理を通しますし
to a symbol that existed in TensorFlow 1
ドキュメントも出します
And then, we'll use the compatibility module
この講演は きっかけです
that I talked about earlier.
それでは 今後の予定について 全容をお伝えします
If there is no perfect replacement,
昨日今日の 2.0アルファ版の話は省略します
we'll use that in order to make sure
これをビルドするのに 時間はかかりました
that your code still works as expected after the conversion.
現在は すでに把握されてる 欠けた機能の実装を
So it's pretty conservative.
いくつか手掛けています
So for instance, the AdamOptimizer
ライブラリと Google を 変換しています
is a very subtle behavior change that mostly probably
これから2~3か月間は 試行と 最適化が 山ほどあります
won't affect you.
リリース候補版は 春を 目指しています
But just in case it might, we will convert it
春とは ある意味 柔軟な概念ですが
to compat.v1 AdamOptimizer.
とにかく 春です
Once the conversion is complete and there were no errors,
リリース候補版が出た後でも
then you can run the new program in TensorFlow 2,
リリース試験や統合試験を 通さなくてなりませんので
and it'll work.
標準のリリースの流れよりも
That's the idea.
少し時間がかかることが予想されます
So it should be pretty easy for you.
しかし リリース候補版が出たら それが完成版です
Hopefully, you won't get trouble.
この過程を確認したいなら ぜひ 行ってみてください
Note that this automatic conversion,
すべてオンラインで追跡できます
it will fix it so it works, but it won't fix your style
GitHub TensorFlow 2 trackerに 載っています
to the new TensorFlow 2 style.
特定の機能を探したり 進捗状況を知りたいだけでも
That cannot be done automatically.
毎日更新されているか 行って確認してください
And there's a lot to learn about this process,
溜まったバグが 最終的に ここに来るので 進捗状況を知ることができます
so if you want to know more, check out the talk by Anna
ですから みなさんあっての TensorFlow 2です
and Tomer tomorrow at 10:30 about 2.0
今までも不具合がありますが
and porting your models.
将来は これ以上に みなさんに試行していただきたいです
That'll be worthwhile.
動作についての情報を お寄せください
Of course, as we go through this process at Google,
本日 アルファ版を インストールしてください
we'll also publish a lot more documentation.
これで みなさんが作ったものを とても見たいので
But this talk is the best start.
アルファ版をインストールし
All right.
tensorflow.org/r2.0にある ドキュメントを確認してください
So let me give you an idea about the timeline of all of this.
そうすれば TensorFlow 2の 動きが わかると思います
We have cut 2.0 alpha today or yesterday--
今後2~3か月で さまざまな側面を正確に伝える
it took some time building it.
多くのコンテンツが発表されるでしょう
We're now working on implementing some missing
では これからカーメルが
features that we already know about.
TensorFlow 2.0の 高レベルAPIについてお話しします
We're converting libraries.
ありがとうございました
We're converting Google.
[カーメル・アリソン TensorFlowエンジニアマネージャー]
There's lots of testing, lots of optimization
こんにちは TensorFlowエンジニアマネージャーの
that's going to happen over the next couple of months.
カーメル・アリソンです
We're targeting to have a release candidate in spring.
マーティンが 今 TensorFlow 2.0と はじめ方を お話ししましたので
Spring is a sort of flexible concept--
私は 高レベルAPIに 導入されるものと機能について
[LAUGHTER]
少し お話しします
But in spring.
まず始めに 高レベルAPIとは何でしょうか?
After we have this release candidate,
機械学習モデルをビルドするとき 多くの共通部品と繰り返し作業があります
it still has to go through release testing and integration
家を建てるみたいにね
testing, so I expect that to take a little bit longer than a
高レベルAPIは モデルをより簡単に
for our regular release chains.
繰り返しビルドし 測定する支援ツールです
But that's when you can see an RC, and then,
マーティンが2~3年前に 言ったとおり
eventually, a final.
TensorFlowは 我々が提供する高レベルAPIの1つ
So if you want to follow along with the process, please do so.
Kerasに適応しています
All of this is tracked online.
Kerasの主な仕事は モデルビルドの特定です
It's all on the GitHub TensorFlow 2 project tracker.
複数の機械学習フレームワークと共働し
So I would just go and look at that
レイヤーや モデルや 損失や 最適化などを定義するための
to stay up to date if you were looking
共有言語を提供します
for a particular feature or just want to know what's going on.
我々はTensorFlowの中心部に
If you file any bugs, those end up there as well so everybody
TensorFlowに 最適化させたバージョンの
knows what's going on.
Kerasを実装しました
So TensorFlow 2 really wouldn't be possible without you.
その高レベルAPIを TF Kerasと呼びます
That has been the case already.
TF Kerasの使用経験者は 手を上げてくれますか?
But in the future, even more so, we'll need you to test this.
なるほど たくさんいますね
We'll need you to tell us what works and what doesn't.
では 次のスライドは 見慣れていますね
So please install the alpha today.
これはKerasの 最もシンプルな書き方です
We're extremely excited to see what you can create with us.
シンプルですよね
So please go, install the alpha, check out the docs.
これは 学びやすく 最初からPython型にビルドしました
They're at tensorflow.org/r2.0.
これは 機械学習の世界へ 招待するきっかけです
And with that, I think you should probably
こちらのコードは 全体モデルの定義と 繰り返される実行を表しています
hear about what it's like to be working with TensorFlow 2.
つまり みなさんがモデル構造の 設計や変更をするのに
We'll have plenty of content over the next couple of days
多くの定型文を 書く必要がなく 簡単です
to tell you exactly about all the different aspects of it.
同時に 継承や インターフェースに頼ることで
But we'll start with Karmel, who will speak about high level
Kerasは非常に柔軟で カスタマイズが利きます
APIs in TensorFlow 2.0.
これは機械学習の アプリケーションには重大です
Thank you
サブクラスモデルがあるので
[APPLAUSE]
任意のモデル構造を定義したり
KARMEL ALLISON: Hi.
実行の各段階で起きることを 変更したり
My name is Karmel Allison, and I'm an engineering manager
やりたいなら 繰り返し実行を 全体的に変更できます
for TensorFlow.
つまり Kerasは シンプルで実践的なのです
Martin just told you about TensorFlow 2.0
誰もが使い方を理解できます
and how to get there. and I'm going
しかし TF Kerasは 小さいモデル用の ビルドだという問題があります
to tell you a little bit about what we're bringing
多くの機械学習の問題は
in our high level API and what you can
Googleの内部を見ても
expect to find when you arrive.
沢山の大きなスケールで 操作が必要ということです
But first, what do I mean when I say high level APIs?
そのためのEstimatorsです
There are many common pieces and routines
Estimatorsは最初から配信まで ビルドされたもので
in building machine learning models, just
無条件に 数百に渡る機械の フォールトトレラントに対応します
like building houses.
こちらは とても好まれている Wide & Deepモデルで
And with our high level APIs, we bring your tools
定義するための研究に長年をかけた 機械学習界の主要な動作ですが
to help you more easily and reproducibly build your models
トレーニングと展開のためには ビルドインとして利用できます
and scale them.
つまり Estimatorsは パワフルな機械です
As Martin mentioned, a couple of years
しかし みなさんの言うように 急な学習曲線がありますので
ago, TensorFlow adopted Keras as one of the high level
どのパーツをどこにつなげるか 見つけ出すのは
APIs we offered.
常に容易とは限りません
Keras is, at its heart, a specification
EstimatorsをTF Kerasに ビルドすることで
for model building.
我々は この2年間に 多くのことを学びました
It works with multiple machine learning frameworks,
我々が行き着いたのは シンプルなAPIと 拡張できるAPI
and it provides a shared language
どちらを選択することは 考えないということです
for defining layers, models, losses, optimizers, and so on.
我々が欲しいのは 整理整頓から大規模なものまで
We implemented a version of Keras
無条件に使える高レベルAPIです
that has been optimized for TensorFlow
ですので TensorFlow 2.0では レイヤーとモデルをビルドするために
inside of core TensorFlow, and we
Keras APIを標準化しました
called it TF Keras, one of our high level APIs.
我々は Estimatorsのパワーを すべてTF Kerasに注ぎ込んだので
Raise your hand if you used TF Keras already?
プロトタイプから 分散型トレーニング 製品の提供に至るまでを
OK, a lot of you.
一気に動かすことができます
That's good, because this next slide will seem familiar.
では 本題です
In its simplest form, Keras is just that, simple.
これをどうやたでしょう?
It was built from the ground up to be
これは TensorFlow 1.13の中の TF Kerasモデルの定義です
Pythonic and easy to learn.
これが 2.0の中の 同一のモデル定義です
And as such, it has been instrumental in inviting people
コードがまったく同じことに お気づきの方もいますね
in to the machine learning world.
では 何が違うのでしょう?
The code here represents an entire model definition
TensorFlow 2.0がもたらす 他のすべての機能と
and training loop, meaning it's really easy for you
Kerasを統合するために 我々は 多くのことをしました
to design and modify your model architectures without needing
例えば 1.13では 内部でセッションを走らせる
to write tons of boilerplate.
グラフベースモデルを ビルドしましたが
At the same time, by relying on inheritance and interfaces,
2.0では同じモデル定義を 変更せずに
Keras is extremely flexible and customizable,
Eagerモード内で走らせています
which is critical for machine learning applications.
これはEagerができることの すべてに利点があります
Here we have a subclass model.
こちらはパイプラインのデータセットです
I can define arbitrary model architectures,
動作は まるでNumPy配列のように デバッグが容易で
modify what happens at each training step,
Kerasモデルへの流れが自然です
and even change the whole training loop if I want to.
しかし同時に データセットは
Which is to say, Keras is simple and effective.
パフォーマンスの 最適化がされますので
Anyone can figure out how to use it.
ひとつのデータセットで 繰り返しトレーニングできて
But we had a problem, TF Keras was built for smaller models.
そのうえ パフォーマンスは最小です
And many machine learning problems,
Keras内のデータセットで パフォーマンスが成功するのは
including the ones we see internally at Google,
Eagerコンテキスト内でも グラフの利点をくみ取れるからです
need to operate at a much larger scale.
Eagerがデバッグと プロトタイピングを容易にし
And so we have estimators.
その間ずっと Kerasが内部で Eagerフレンドリーな
Estimators were built from the ground up to distribution
モデル追跡機能をビルドします
and scale with fault tolerance across hundreds of machines,
そして TensorFlowのランタイム時に
no questions asked.
パフォーマンスとスケーリングを 最適化させます
This here is the much-loved wide and deep model,
つまり run_eagerlyフラグにより
a workhorse of the machine learning
Eager内でモデルを 段階ごとに明示して走らせるのです
world that took many years of research to define
この例は やり過ぎかもしれませんが
but is available as a built-in for training and deployment.
run_eagerlyなら モデルをプロトタイピングしている間に
Which is to say, estimators are powerful machines.
デバッグ用のPython制御フローと Eagerモードが使用できます
But you've told us that there's a steep learning curve,
2.0における その他の大きな変更点は
and it's not always easy to figure out
Kerasの項目の下で
which parts to connect where.
TensorFlowに多くのAPIを 連結させたことです
And we learned a lot in the past two years
重複したクラスを減らし
building out estimator in TF Keras
使用するコードとタイミングが 簡単にわかるようにしました
And we've reached the point that we
では 1セットの オプティマイザーがあります
don't think you should have to choose
そのオプティマイザーは TensorFlow中で動作し
between a simple API and a scalable API.
Eagerモードを出入りし ひとつの機械でも分散しても動作します
We want a higher level API that takes
一般的なPython属性のように
you all the way from [INAUDIBLE] to planet scale,
ハイパーパラメーターを 検索したり設定でき
no questions asked.
オプティマイザーたちは すべてシリアライズできます
So in TensorFlow 2.0, we are standardizing on the Keras API
重量や設定は
for building layers and models.
TensorFlowのチェックポイント フォーマットにも
but we are bringing all the power of estimators
Kerasのバックエンド診断的 フォーマットにも保存できます
into TF Keras, so that you can move from prototype
以前のTFとKerasのメトリクスを すべて網羅して
to distributed training to production serving in one go.
必要なときに容易にサブクラス化する メトリクスもあります
OK, so brass tacks--
損失関数も 同様に 選択すれば 頻回に使われるビルドインと
how are we doing this?
カスタマイズ可能なインターフェースの 1セットに連結しています
Well, this is a TF Keras model definition in TensorFlow 1.13.
そして レイヤーも1セットあります
And this is the same model definition in 2.0.
Kerasのレイヤースタイルの中に ビルドされています
[LAUGHTER]
つまり それらは クラスベースであり
Some of you may notice the code is exactly the same.
設定可能ということです
OK, so what actually is different?
レイヤー内のビルドは たくさんあります
Well, we've done a lot of work to integrate Keras
Keras APIの仕様から来たものを 全て含んでいます
with all of the other features that TensorFlow 2.0 brings
TensorFlow内 RNNレイヤーのところの
to the table.
1セットのレイヤーは 特に気にかけます
For example, in 1.13 this built a graph-based model that
TensorFlowのRNNレイヤーの 使用経験者は手を上げてください
ran a session under the hood.
こちら側ではあなただけですね
In 2.0, the same model definition
TensorFlow 1.xバージョンには
will run in Eager mode without any modification.
LSTM と GRUのいくつか異なる バージョンがありました
This lets you take advantage of everything Eager can do for us.
そして cuDNNのパフォーマンスを 最大にするために最適化していたデバイスを
Here we see that our data set pipeline behaves just
前もって知っておく必要があります
like a numpy array, easy to debug
2.0ではLSTMレイヤーの バージョンは ひとつ
and flows natively into our Keras model.
GRUレイヤーのバージョンも ひとつです
But at the same time, data sets have
ランタイムのときに 使用可能なデバイス操作が
been optimized for performance so that you
自動的に書き込まれるので 選ばなくて済みます
can iterate over and train with a data set
こちらのコードで cuDNN kernelが走ります
with minimal performance overhead.
GPUがあれば使用できますが 使えるGPUがなくても
We're able to achieve this performance
CPUのOPSに戻ります
with data sets in Keras by taking advantage of graphs,
それらに加えて
even in an Eager context.
ビルドインのセットに入っていない レイヤーが必要なら
Eager makes debugging and prototyping easy,
TF Kerasが容易にサブクラスにでき カスタマイズできるAPIを提供しますので
and all the while Keras builds an Eager-friendly function,
既存レイヤーのトップを 刷新してください
under the hood, that tracks your model,
実はこれが TensorFlow アドオンの
and the TensorFlow runtime then takes
コミュニティレポジトリが 動作する仕組みです
care of optimizing for performance and scaling.
Kerasベースのクラスの上に ビルドすることで
That said, you can also explicitly run
アドオンが 特定化された ある複雑なレイヤーと
your model step-by-step in Eager mode with the flag run_eagerly.
メトリクスと オプティマイザーなどを
Even though for this example, it might be overkill,
TensorFlowコミュニティに 提供するのです
you can see that run_eagerly allows
では APIの合理化を始めます
you to use Python control flow and Eager mode for debugging
次に 我々がしたのは Kerasと
while you're prototyping your model.
TensorFlowにあるすべての ツールや機能の統合です
Another big change coming in 2.0 is
Estimatorsの開発で 重要なツールのひとつは
that we have consolidated many APIs across TensorFlow
特徴カラムと共に渡す 簡単に設定ができる構造化データです
under the Keras heading, reducing duplicative classes
TensorFlow 2.0では データを解読し
and making it easier to know what you should use and when.
直接 下部Kerasレイヤーに投じるための 特徴カラムが使えます
We now have one set of optimizers.
特徴カラムはKerasとも Estimatorsとも共働しますので
These optimizers work across TensorFlow
再生可能データインプット パイプラインを作成するために
in and out of eager mode, on one machine or distributed.
混ぜ合わせたりできます
You can retrieve and set hyperparamters
モデル内にデータがあれば すぐにトレーニングできます
like normal Python attributes, and these optimizers
トレーニング作業を走らせるツールで
fully serializable.
一番人気があるのは TensorBoardです
The weights and configuration can
TensorFlow 2.0になって 嬉しいのは
be saved both in the TensorFlow checkpoint
TensorBoardとKerasの統合が 1行で済むのです
format and the backend diagnostic Keras format.
トレーニング中は
We have one set of metrics that encompasses all the former TF
モデルへコールバックする TensorBoardを加えます
metrics and Keras metrics and allow for easy subclassing
すると トレーニングの進捗状況が出て
if you want even more.
成功と損失がわかります
Losses, similarly, have been consolidated into a single set
そして レイヤーごとに ビルドしたモデルを
with a number of frequently used built-ins and an easily
表示する概念グラフです
customizable interface if you so choose.
追加ボーナスとして
And we have one set of layers, built
モデルの全プロファイルも 同じくコールバックされますので
in the style of Keras layers.
モデルのパフォーマンスも デバイス配置も より理解できますし
Which means that they are class-based
ボトルネックの最小化方法も わかりやすいです
and fully configurable.
パフォーマンスに関して言えば
There are a great number of built in layers, including
tf.distribute.Strategy APIが TensorFlow 2.0に導入されたのは
all of the ones that come with the Keras API specification.
とても嬉しいことです
One set of layers that we took particular care with where
Kerasで元々使われてた トレーニングのワークフローを
the RNN layers in TensorFlow.
分散する戦略の1つであるビルドセットが TensorFlow 2.0に導入予定です
Raise your hand if you've used RNN layers in TensorFlow?
これらのAPIは使いやすいように 設計されており
OK, these slides are for you.
型にはまらないパフォーマンスがあり
[LAUGHTER]
構造とデバイスをさまざまなに 分散させるに 万能です
In TensorFlow V1 we had several different versions
では動作はどうでしょう?
of LSTm and GRUs, and you had to know ahead
Kerasと一緒なら 分散戦略の追加や 代替えは
of time what device you were optimizing for in order
数行のコードでできます
to get peak performance with cuDNN kernels.
ここでは モデルネットワークを 定義したり
In 2.0, there is one version of the LSTM
収集したり 分散戦略の範囲中に合わせることで
and one version of the GRU layer.
複数のGPUに見られた同じモデルを 分散させています
And they select the write operation
分散戦略はKerasを通して TensorFlowへ統合されたので
for the available device at runtime
数行のコードで 多くのことができます
so that you don't have to.
一回分ごとに データがGPUに プリフェッチされ
This code here runs the cuDNN kernel
変数はAllreduceを使って すべての使用可能デバイスに
if you have GPUs available, but also
一気にミラーが送られます
falls back to CPU ops if you don't have GPUs available.
複数のGPUで 90%以上の スケーリング効率があります
In addition to all of those, if you
つまり モデルをコード変更することなく Kerasの他の利便性を失うことなく
need layers that are not included in the built-in set,
スケールアップできるのです
TF Keras provides an API that is easy to subclass and customize
一度 モデルをトレーニングすると
so that you can innovate on top of the existing layers.
製品システムや携帯電話や 他のプログラミング言語と共に使うための
This, in fact, is how the community repository
パッケージが欲しくなります
TensorFlow add-ons operates.
Kerasモデルは保存されたモデルや
They provide specialized and particularly complex layers--
TensorFlowエコシステムで動作する シリアライゼーションフォーマットへ
metrics, optimizers, and so on--
直接エクスポートできます
to the TensorFlow community by building
APIの細部を調整している間 この機能は実験的ですが
on top of the Keras base classes.
本日 2.0に行けば モデルをTF ServingやTF Liteなどに
All right.
簡単にエクスポートして使用できます
So we streamlined API--
また それらのモデルを 簡単にリロードしてPythonへ戻し
that's a start.
普段のワークフローで トレーニングの継続や使用も可能です
The next thing we did was integrate Keras
アルファ版については ここまでです
across all of the tools and capabilities
まだ 終わりませんよ
that TensorFlow has.
今後 数か月間の予定を 少しお話しします
One of the tools we found critical to the development
複数のGPUに分散すると お話ししましたが
of estimators was easily configurable structured data
これは序章です
passing with feature columns.
同一モデルコードの使用で 戦略のスワップアウトも
In TensorFlow 2.0 you can use feature columns
複数ノードへのスケールアップも 可能になります
to parse your data and feed it directly
こちらに先ほど見たものと 同じKerasモデルです
into downstream Keras layers.
これは複数の機械に 分散されていて
These feature columns work both with Keras and estimators,
以前よりも早く モデルをトレーニングするために
so you can mix and match to create reusable data input
集合体OPSを使って すべてが同時に動作しています
pipelines.
複数動作するミラー戦略は 現在 Allreduce用の
OK.
RingとNickelをサポートし
So you have data in your model, and you're ready to train.
型破りの素晴らしい パフォーマンスができます
One of the most loved tools we have for running your training
このAPIは開発中ですが
jobs is TensorBoard.
複数の動作トレーニング同期に対し
And I'm pleased to say in TensorFlow 2.0,
TensorFlow由来の解決策に 興味があるなら
TensorBoard integration with Keras is as simple as one line.
今夜から 試すことができます
Here we add a TensorBoard callback to our model
そして 非常に嬉しいことに Kerasと分散戦略を使えば
when training.
TPU上のモデル分散にも 同じコードを使うことができるでしょう
And this gets us both our training progress--
実際 TPUで作業するには
here we see accuracy and loss--
次のTensorFlowリリースを 待つ必要がありますが
and a conceptual graph representing the model we
リリースされたら Google Cloud TPUでも
built layer-by-layer.
その戦略は動きますし
As an added bonus, this same callback even
Colabと一緒なら TPUに直接アクセスできます
includes full profiling of your model,
最終版の2.0を リリースするにあたって
so you can better understand your model's performance
スケーラビリティのKerasへの導入は 継続していきます
and device placement, and you can more readily find
本日 Estimatorが行った 複数ノードの非同期的トレーニングなどの
ways to minimize bottlenecks.
パラメーターサービス戦略は 提供が可能でしょう
Speaking of performance, one of the exciting pieces
Wide&Deepのように もっと高レベルAPIが必要な人のための
we're bringing to TensorFlow 2.0 is
Keras APIから直接 詰め込まれた Estimatorも披露されました
the tf.distribute.Strategy API.
Googleで走っているような 最大規模のモデルのために
In TensorFlow 2.0 we will have a set
多くの機械へ分割される変数の サポートも追加されました
of built in strategies for distributing your training
予告編は以上となります
workflows that work natively with Keras.
2.0のプレビューを確認して
These APIs have been designed to be easy to use,
まだの方は TK Kerasを試してください
to have great out-of-the-box performance,
質問のある方は Kerasや高レベルAPIや
and to be versatile enough to handle many different
TensorFlowへの統合方法などは 今日 いろいろ聞くことになるでしょう
distribution architectures and devices.
マーティンが言ってたように 明日はワークショップがあります
So how do they work?
Well, with Keras you can add and switch distribution strategies
with only a few lines of code.
Here we are distributing the same model you just
saw across multiple GPUs by defining the model network,
compiling, and fitting within the distribution strategy
scope.
Because we've integrated distribution strategies
throughout Keras in TensorFlow, you get a lot
with these few lines of code.
Data will be prefetched to GPUs batch-by-batch,
variables will be mirrored in sync
across all available devices using allreduce,
and we see greater than 90% over multiple GPUs.
This means you can scale your model up without changing code
and without losing any of the conveniences of Keras.
Once you've trained your model, you're
likely going to want to package it for use with production
systems, mobile phones, or other programming languages,
Keras models can now export directly
to saved_model, the serialization
format that works across the TensorFlow ecosystem.
This functionality is experimental
while we iron out a few API details, but today,
and going into 2.0, you can easily
export your models for use with TF Serving, TF Lite, and more.
You can also easily reload these models back
into Python to continue training and using
in your normal workflow.
So that's where we are today in the alpha.
But we're obviously not done yet,
so let me tell you a little bit about what's coming up
in the next few months.
We talked about distributing over multi-GPU,
but that's just the start.
Using the same model code, we can swap out our strategy
and scale up to multiple nodes.
Here we take the same Keras model
we just saw and distribute it across multiple machines,
all working in sync using collective ops
to train your model faster than ever before.
Multi-worker mirrored strategy currently supports ring
and nickel for allreduce, which allows us to achieve great
out-of-the-box performance.
This API is still being developed,
but you can try it out today in the nightlies
if you are interested in a TensorFlow-native solution
to synchronous multi worker training.
And we are very excited to say that using Keras
and distribute strategies you will also
be able to use the same code to distribute your model on TPUs.
You'll have to wait for the next TensorFlow release for this
to actually work on TPUs.
But when it's released, this strategy
will still work on Google Cloud TPUs
and with Colab, which can now access TPUs directly.
And as we approach the final 2.0 release,
we will continue bringing scalability into Keras.
We will be enabling distribution with parameter service
strategy, which is the multi-node asynchronous
training that estimator does today.
We will also be exposing canned estimator like wide and deep
directly from the Keras API for those of you
who want a higher level higher level API.
And we will be adding support for partitioned variables
across many machines for some of the largest scale models,
like those we run at Google.
And that's just a sneak peak.
So please do check out the 2.0 preview
and try out TF Keras if you haven't already.
If you have more questions, you'll
be hearing more throughout the day about Keras and high level
API and how they integrate across TensorFlow.
And we also have a workshop tomorrow that Martin mentioned.
[MUSIC PLAYING]