Placeholder Image

Subtitles section Play video

  • [MUSIC PLAYING]

  • MARTIN WICKE: I'm Martin Wicke.

  • I'm the engineer lead for a TensorFlow 2,

  • and I am going to, unsurprisingly, talk

  • about TensorFlow 2.

  • TensorFlow has been extremely successful.

  • 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.

  • And we learned a lot from how people did it.

  • 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

  • And we know.

  • At sometimes it's been a little painful.

  • So using sessions wasn't the most natural thing

  • to do when coming from regular Python.

  • And the TensorFlow API has grown over time

  • and got a little bit cluttered, a little bit confusing.

  • In the end, you can do everything with 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,

  • you need easier debugging, there's a lot of clutter.

  • 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

  • on the bleeding edge of development

  • have probably played with a nightly.

  • You have installed it.

  • You have tested it.

  • You have found issues.

  • You have fixed issues.

  • So thank you very much for your help.

  • You can now install the alpha release of TensorFlow 2

  • using just pip install --pre tenserflow.

  • And you can go and play with it.

  • So what has changed?

  • When we create TensorFlow 2, really the biggest focus

  • is on usability.

  • We've adopted Keras as the high level API for TensorFlow.

  • We've integrated it very deeply with TensorFlow.

  • Keras gives you a clear path of how to develop models,

  • how to deployment models.

  • It has a [INAUDIBLE] API that makes people productive,

  • and we know that it gets you started quickly.

  • TensorFlow also includes a complete implementation

  • of Keras, of course.

  • 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.

  • 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.

  • [LAUGHTER]

  • But you still get all the benefits

  • of working with A graph--

  • 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,

  • 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.

  • We've organized the API.

  • We've made sure that the API looks and feels consistent.

  • 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

  • all of these interfaces.

  • And we've defined exchange formats

  • that'll allow you to move all throughout this ecosystem

  • without hitting any barriers.

  • We have removed a lot of stuff from TensorFlow,

  • but that doesn't mean that it's not--

  • 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

  • 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.

  • And this allows framework authors

  • to build on top of TensorFlow while maintaining

  • interoperability with the rest of the ecosystem.

  • And you'll hear a lot of these examples later.

  • There'll be talk about TF agents later today.

  • 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

  • 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.

  • 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

  • be writing a lot of migration guides.

  • we have started that already, and some of them

  • are online and will provide a lot of best practices for you.

  • 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--

  • we call it tf.compat.v1--

  • which contains all of the 1.x API.

  • 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.

  • We're also publishing a script which will automatically

  • 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,

  • 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

  • that it changed.

  • And you can see, if you look at what changed,

  • 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.

  • 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

  • for you.

  • And then, if all else fails, sometimes there

  • isn't really a perfect equivalent in TensorFlow 2

  • 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,

  • 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

  • is a very subtle behavior change that mostly probably

  • won't affect you.