
Chinese: 
大家好，谢谢各位的到来
- 我叫Daniel
- 我叫Nikhil
我们来自Google Brain团队
今天我们很高兴跟大家
谈谈JavaScript
Python一直是科学计算的
主流语言之一
一直是这样的
且有很多有关Python的
函式库及工具
但这样就是极限吗？
今天我们在这里跟大家说说
使你们信服
JavaScript和浏览器
有很多其他的功能
TensorFlow Playground
就是一个很棒的例子
我很好奇，有多少人之前
见过TensorFlow Playground？
哇！很少耶
我很高兴
对于那些还未见过的

English: 
♪ (music) ♪
(applause)
Hi, everyone. Thanks for coming today.
- My name is Daniel.
- My name is Nikhil.
We're from the Google Brain team,
and today we're delighted
to talk about JavaScript.
So, Python has been
one of the mainstream languages
for scientific computing,
and it's been like that for a while.
And there's a lot of tools
and libraries around Python.
But is that where it ends?
We're here today to talk--
to convince you that JavaScript
and the browser
have a lot to offer.
And TensorFlow Playground
is a great example of that.
I'm curious-- how many people
have seen TensorFlow Playground before?
Oh, wow! Quite a few.
I'm very glad.
So, for those of you that haven't seen it,

Chinese: 
可以在讲座后到
playground.tensorflow.org.看看
这是小型神经网络的
隐身浏览器可视化
而且它实时显示
所有网络的内部
正如练习一样
这真的很有趣
在教育界取得巨大成功
我们收到很多来自
高中和大学的电邮
他们使用这个材料
向学生讲授机器学习
在我们推出Playground后
我们想知道，
“为什么它如此成功呢？”
我们认为其中一个重要原因是
它在浏览器中
浏览器就是你们所建立的东西
而放在一个独特的平台
只需用一个链接就可跟任何人分享
那些打开应用的用户
无需安装任何驱动程序
或任何软件
它就能正常运作
另一件事就是
浏览器是高度互动的
无论你们建立了什么东西
用户都可参与其中

English: 
you can check it out after our talk
at playground.tensorflow.org.
It is an in-browser visualization
of a small neural network,
and it shows, in real time,
all the internals
of the network as it's training.
And this was a lot of fun to make.
It had a huge, educational success.
We've been getting emails
from high schools and universities
that have been using this
to teach students about machine learning.
After we launched Playground,
we were wondering,
"Why was it so successful?"
And we think one big reason
was because it was in the browser.
And the browser is this unique platform
where the things you build,
you can share
with anyone with just a link.
And those people that open your app
don't have to install any drivers
or any software,
it just works.
Another thing is the browser
is highly interactive,
and so the user is going to be engaged
with whatever you're building.

Chinese: 
另一件重要事情是浏览器 -
我们在Playground里没有利用它
但是浏览器能够访问传感器
就像麦克风，相机和加速计
所有这些传感器都在
标准化API背后
适用于所有浏览器
最后且最重要的事情是
来自这些传感器的数据
不必留给客户端处理
不必上传任何东西到服务端
以保护隐私
现在我们创建的playground
由一个小型神经网络驱动
我们撰写的300行
Vanilla JavaScript代码
作为一次性函式库
它没有进行缩放
只是简单的循环
亦未设计成可重用
但是我们很清楚
如果为大家打开大门
将机器学习与浏览器合并在一起
就必须建立一个函式库
而我们成功了

English: 
Another big thing is that browsers--
we didn't take advantage
of this in the Playground,
but browsers have access to sensors,
like the microphone and the camera
and the accelerometer.
All of these sensors
are behind standardized APIs
that work on all browsers.
And the last thing,
the most important thing,
is the data that comes from these sensors
doesn't ever have to leave the client.
You don't have to upload anything
to the server, which preserves privacy.
Now, the playground that we built
is powered by a small neural network,
300 lines of vanilla JavaScript
that we wrote as a one-off library.
It doesn't scale,
it's just simple for-loops,
and it wasn't engineered to be reusable.
But it was clear to us
that if we were to open the door
for people to merge
machine learning and the browser,
we had to build a library.
And we did it!

English: 
We released deeplearn.js,
a JavaScript library
that is GPU-accelerated
and it does that via WebGL,
which is a standard in the browser,
that allows you to render 3D graphics.
We utilize it to do linear algebra for us.
And deeplearn.js allows you to both
run inference in the browser
and training entirely in the browser.
When we released it,
we had an incredible momentum.
The community took deeplearn.js
and took existing models in Python,
imported it into the browser
and built interactive fun things with it.
So, one example is the Style Transfer.
Another person imported the character RNN,
and then built a novel interface
that allows you to explore
all the different
possible endings of a sentence,
all generated by the model in real time.
Another example
is a font-generative model--
there was a post about this.

Chinese: 
我们发布了 deeplearn.js
一个JavaScript函式库
它的GPU加速了运算
且通过WebGL来完成
这符合浏览器的标准
允许你们表达3D图形
我们利用它来处理线性代数
而deeplearn.js可让你们
同时在浏览器中运行推论
并在浏览器中进行训练
当我们发布时势头不俗
社群采用了deeplearn.js
并使用Python的现有模型
将其导入浏览器
并使用它构建了有趣的互动物件
Style Transfer就是一个很好的例子
另一个开发人员导入字符级RNN
然后创建了一个全新界面
让你们可探索
一个句子所有不同的结尾
而全部均由模型实时生成
另一个例子是字体生成模型
有一篇文章关于此主题

English: 
The person that built it
allowed users to explore
the hidden dimensions,
the interesting dimensions
in the embedding space.
And you can see how they relate
to boldness and slantedness of the font.
And there were even educational examples,
like Teachable Machine
that built this fun little game
that taught people
how computer vision models work,
so people could interact
directly with the webcam.
Now, all the examples I showed you
point to the incredible momentum
we have with deeplearn.js.
And building on that momentum,
we're very excited today
to announce that deeplearn.js
is joining the TensorFlow family.
And with that, we are releasing
a new ecosystem of libraries and tools
for machine learning with JavaScript,
called TensorFlow.js.
Now, before we get into the details,
I want to go over three main use cases
of how you can use TensorFlow.js today,

Chinese: 
创建者允许用户探索
隐藏的维度
在嵌入式空间发现有趣的维度
你们可以看到
这如何跟斜体和粗体有关
甚至还有与教育相关的事例
例如Teachable Machine
建立了这个有趣的小游戏
教导人们计算机视觉模式怎样运作
使人们可以使用网络摄像头直接互动
我给你们的所有例子
指向我们deeplearn.js的
不俗势头
在这个势头的基础上
我们今天非常高兴地宣布
deeplearn.js正式加入TensorFlow家族
借此我们发布了使用JavaScript
以进行机器学习的
函式库及工具的全新生态系统
称为TensorFlow.js
在我们深入讨论细节之前
我想介绍三个主要用例
你们今天如何使用TensorFlow.js

English: 
with the tools and libraries
that we're releasing.
So, one use case is you can write models
directly in the browser,
and this has huge
educational implications--
think of the playground
that I just showed.
A second use case is--
a major use case is you can take
a pre-existing model,
pretrained model in Python,
use a script, and you can import it
into the browser to do inference.
And a related use case is the same model
that you take to do inference,
you can retrain it,
potentially with private data
that comes from those sensors
of the browser, in the browser itself.
Now, to give you more of a schematic view,
we have the browser that utilizes WebGL
to do fast, linear algebra.
On top of it, TensorFlow.js
has two sets of APIs:
the ops API,
which used to be deeplearn.js,
and we worked hard to align
the API with TensorFlow Python.
It is powered by an automatic
differentiation library

Chinese: 
以及正在发布的工具及函式库
第一个用例就是你们可以
在浏览器中直接撰写模型
这有重要的教育含义-
想想我刚才展示的playground
第二个用例是
一个主要的用途是
你们可以采取
一个预先存在的模型
在Python中的预训练模型
使用脚本，就可以把它
导入浏览器进行推论
另一个相关用例就是
你们进行推论的同一样模型
可以重新训练它
有可能地使用那些来自浏览器的
传感器的私人数据或浏览器本身
现在给你们较示意图更多的资料
我们有使用WebGL的浏览器
以快速处理线性代数
更最重要的是TensorFlow.js
有两套APIs:
Ops API，它曾经是deeplearn.js
而我们曾努力将API
与TensorFlow Python对齐
它由自动微分函式库提供支持

Chinese: 
这与Eager模式类似
最重要的是我们有一个
高阶的API LayerAPI
这使你们能夠使用最佳方法
与高阶的组件以撰写模型
我们今天亦非常高兴地宣布
我们可以发布一项工具
这采用现有的Keras模型
或TensorFlow SavedModel
将它自动导入浏览器中执行
现在向你们展示一个API示例
我们将要通过一个简单程序
以试图学习二次函数的系数
我们尝试理解的系数
来自数据的a，b和c
我们有来自TensorFlow.js的
import tf
对于你们那些不了解的
这是JavaScript的标准ES6导入
这很常见的
我们有三个张量：a，b和c
我们将之标示为变量
这意味着它们是可变的
而优化程序可以更改它们

English: 
that is built analogous to Eager mode.
And on top of that,
we have a high-level API Layers API
that allows you to use best practices
and high-level building blocks
to write models.
What I'm also very excited
today to announce
is that we're releasing tools
that can take an existing Keras model
or TensorFlow SavedModel,
import it automatically
for execution in the browser.
Now, to show you an example of our API,
we're going to go over a small program
that tries to learn the coefficients
of a quadratic function.
So the coefficients we're trying to learn
are a, b, and c from data.
So we have our import tf
from TensorFlow.js.
For those of you that don't know,
this is a standard
ES6 import in JavaScript--
very common.
We have our three tensors: a, b, and c.
We mark them as variables,
which means that they are mutable
and the optimizer can change them.

English: 
We have our f(x) function
that does the polynomial computation.
You can see here familiar API,
like tf.add and tf.square,
like TensorFlow.
In addition to that API,
we also have a Chaining API
which allows you to call
these map operations on Tensors itself.
And this leads to better readable code
that is closer to how we write math.
Chaining is very popular
in the JavaScript world.
So that's the feed-forward
part of the model.
Now, for the training part,
we need a loss function.
So here is a loss function
that is just the mean-squared error
between the prediction and the label.
We have our optimizer, an sgd optimizer,
and we train the model--
we call optimizer.minimize
for some number of EPOCHS.
And here I want to emphasize,
for those of you
that have used tf.figure before
or the talk before us, Alex's talk,

Chinese: 
我们有f(x)函数
可进行多项式计算
在这里可看到熟悉的API
例如 tf.add 及 tf.square
例如TensorFlow
除了那个API之外
也有一个Chaining API
这可以让你们在张量本身
呼叫这些 map 操作
这导致更好的可读性代码
更接近我们的数学书面语
在JavaScript世界中
链是很常见的
这是模型的前馈部分
对于训练部分
我们需要一个损失函数
这里是一个损失函数
这只是一个在预测和
标签之间的均方误差
我们有优化器
一个 sgd 优化器
我们训练那个模型 -
称之为optimizer.minimize
为了一些EPOCHS
在这里我要强调
你们之前曾经使用tf.figure
或在我们之前听过讲座
亚历克斯的讲座

Chinese: 
TensorFlow.js的API
与Python的Eager API是一致的
好吧，很清楚的这并不是
大多数人写机器学习的方法
因为那些低阶线性代数操作
可能非常冗长
为此，我们有Layers API
为了向你们展示一个例子
我们要建立一个循环神经网络
它学会将两个数字加起来
复杂的部分是那些数字
例如90 + 10，由逐个字符馈送
然后神经网络
须与LSTM元件保持一个内部状态
然后这个状态进入解码器
解码器必须逐个字符输出100
这是一个序列-到-序列的模型
这听起来有点复杂
但是使用Layers API
就不须那么多行的代码
我们有TensorFlow.js的import tf

English: 
the API in TensorFlow.js
is aligned with the Eager API in Python.
Alright, so clearly that's not how
most people write machine learning,
because those low-level linear
algebra ops can be quite verbose.
And for that, we have our Layers API.
And to show you an example of that,
we're going to build
a recurrent neural network
that learns to sum two numbers.
But the complicated part
is that those numbers,
like the number 90+10,
are being fed character by character.
And then the neural network
has to maintain an internal state
with an LSTM cell.
That state then gets passed
into a decoder,
and then the decoder has to output 100,
character by character.
So it's a sequence-to-sequence model.
This may sound a little complicated,
but with the Layers API
is not that many lines of code.
We have our import tf from TensorFlow.js.

English: 
We have our sequential model,
which just means it's a stack of layers.
For those of you that are familiar
with tf.layers in Python or Keras,
this API looks very familiar.
The first two layers are the encoder,
the last three layers are the decoder.
And that's our model.
We then compile it
with a loss, an optimizer,
and a metric we want to monitor,
like accuracy,
and we call model.fit, with our data.
Now, what I want to point out here
is the await keyword.
So, model.fit is an asynchronous call,
which means--
because in practice that can take
about 30 or 40 seconds in a browser.
And in those 30 or 40 seconds,
you don't want the main UI thread
of the browser to be locked.
And this is why you get a callback
with a history object after that's done.
And in between, the GPU
is going to do the work.
Now, the code I showed you

Chinese: 
还有我们的顺序模型
这意味着它是一堆层
对于那些熟悉Python或Keras的
tf.layers 的开发人员
这个API看起来很熟悉吧
前两层是编码器
后三层是解码器
这就是我们的模型
然后我们替它编译
须用一个损失一个优化器
以及我们想要监控的指标
例如精确度
我们用我们的数据调用model.fit
现在我想在这里指出
这个关键字等待
因此model.fit是一个异步调用
意思是--
实际上在浏览器中需时约30或40秒
在那30或40秒中
你们不想浏览器的
主UI线程被锁定
这就是在完成之后
有个回调与历史对象的原因
而在此之间
GPU将要完成所需工作
现在我给你们看的代码

English: 
is when you are trying
to write models directly--
when you want to write models
directly in the browser.
But, as I said before, a major use case,
even with deeplearn.js
was people importing models
that were pretrained,
and they just want to do
inference in the browser.
And before we jump
into the details of that,
I want to show you a fun little game
that our friends
at Google Brand Studio built
that takes advantage
of an automatically pretrained model
ported into the browser.
And the game is called
Emoji Scavenger Hunt.
And the way it works--
I'm going to show you here
a real demo with the phone.
It's in the browser.
Let me see.
Can I see here?
So you can see I have a Chrome browser
opened up on a Pixel phone.
You can see the URL on the top.
And the game uses the webcam
and shows me an emoji,
and then I have some time,
some number of seconds
to find the real version
item of that emoji

Chinese: 
就是你们尝试直接撰写的模型
你们想在浏览器中直接撰写模型
正如我之前所说，一个重要的用例
即使deeplearn.js
是开发人员用作预训练的模型
而他们只想在浏览器中进行推论
在我们讨论细节之前
我想给你们看看
一个有趣的小游戏
我们Google Brand Studio的朋友建立
这是利用了移植到浏览器的
自动预训练模型
这个游戏称为
Emoji Scavenger Hunt
它的运作方式
我在这里向你们
使用一支真正的手机演示
它在浏览器中
让我看看
我在这里看到吗？
你们可以看到一个Chrome浏览器
在Pixel手机上打开
在顶部可以看到网址
游戏使用了网络摄像头
并给我显示一个表情符号
然后我有一些时间
几秒钟时间找到
表情符号的真实版本

English: 
before the time runs out.
So, before we play,
Nikhil here is going to help me identify
the objects that this game asks.
- You ready?
- (Nikhil) I'm ready.
(Daniel) Alright, let's go.
(countdown beeping)
- Alright. Watch. Do you have a watch?
- (Nikhil) I have a watch.
(phone) Did I spot a velvet?
Go on.
- (Daniel) Whoo! Yay! We got that!
- (Nikhil) Awesome.
(Daniel) Let's see what our next item is.
(countdown beeping)
- (Daniel) Shoe.
- (Nikhil) Shoe.
(Daniel) You got
to help me out here, buddy.
- (phone) Did I spot a--
- (Daniel) Oh, yeah!
- (phone) You found shoe.
- (Daniel) Whoo! We got the shoe!
(Nikhil) Alright, what's next?
(countdown beeping)
(Daniel) Right, it wants a banana.
(Nikhil) A banana? Does anyone have a--
this guy's got a banana!
- (Daniel) Hold, what!
- (Nikhil) This guy's got a banana!
- (Daniel) Come over here.
- (phone) Am I seeing a wall?
- (Daniel) Yay! Alright!
- (Nikhil) Alright!
- (Daniel) Look at us!
- (Nikhil) I'm ready.
We're going to have a high score here.
- (Daniel) Beer!
- (phone) Could that be a hat?
(Nikhil) It's 10:30
in the morning, Daniel!
- (phone) Did I spot a velvet?
- (Nikhil) Let's get back to the talk.

Chinese: 
在时间用完之前
在我们玩之前
Nikhil在这里将会帮助我确定
这游戏提出的对象
- 准备好了吗？
- 我准备好了
好吧，我们开始
- 好的。你有手表吗？
- 我有一只手表
我发现了天鹅绒吗?
继续吧
- 喔！好极了！我们做到了！
- 太棒了
让我们看看下一个物件
- 鞋子
- 鞋子
这里你要帮助我，哥们
- 我发现了--
- 哦，对啊！
- 你找到了鞋子
- 喔！我们找到了鞋子
好吧，接下来呢？
好吧，我想要一根香蕉
一根香蕉？有没有人
这家伙有香蕉！
- 等一下，什么
- 这家伙有一根香蕉
- 过来吧
- 我看到一幅墙吗？
- 耶！好吧！
- 好吧！
- 看看我们
- 我准备好了
我们将会获得很高分
- 啤酒
- 这可能是一顶帽子吗？
现在是早上10点30分，丹尼尔
- 我发现了天鹅绒吗？
- 让我们回到讲座

Chinese: 
- 好吧
- 我想我看到了一个牛奶罐
好吧，我要讲解技术细节
实际上我们如何构建这款游戏
点击器? 对啊
我们所做的是要训练
TensorFlow中的模型
成为Scavenger Hunt游戏的
对象识别器
我们选择了约400个不同的类別
对于这样的游戏这是合理的
手表，香蕉和啤酒
我们所做的是我们使用了
TensorFlow For Poets codelab
而在那codelab
基本上你要做的是
采用预训练的MobileNet模型
如果你不知道MobileNet是什么东西
这是一台最先进的电脑视觉模型
为边缘设备而设
我们实际做的是
拿了那个模型
为这些类別重新进行训练
现在我们有一个Python的对象检测
现在我们如何把它放到浏览器？
我们今天提供了一套工具
帮助你们实际地做到这点
一旦开始，你就作了很大的影响
并让电脑谈话
和所有这些有趣的东西

English: 
- (Daniel) Alright. (chuckles)
- (phone) I think I saw a milk can.
(Nikhil) Alright, so I'm going to jump
into the technical details
of how we actually built that game.
The clicker? Yep.
So, what we did was we trained
the model in TensorFlow
to be an object recognizer
for the Scavenger Hunt game.
We chose about 400 different classes
that would be reasonable
for a game like this,
you know, watches and bananas and beer.
So, what we did was we used
the TensorFlow For Poets codelab.
And in that codelab,
what you essentially do
is you take a pretrained MobileNet model.
And if you don't know what MobileNet is,
it's a state-of-the-art computer
vision model for edge devices.
So what we effectively did
was we took that model
and we retrained it for these classes.
Now we have an object detector
in the Python world.
How do we actually
now get this into the browser?
Well, we provide a set of tools today
that help you actually do that.
Once it's in, you skin the game
and you make the computer talk
and all that kind of fun stuff.

Chinese: 
让我们讲讲如何实际地转换那模型
正如Daniel今天早些时候提到
实际上我们支持两种类型的模型
我们支持TensorFlow SavedModels--
为此有一个转换器
亦有一个转换器
为Keras SavedModels而设
先定义你们的模型
并用Save模式保存它
这是标准方法
同样这是Keras的代码
(听不见)
下一件就是
实际地我们将其转换为Web
今天我们发布了PIT包
这是TensorFlow.js
可以在那里安装
那里有一个脚本
让你们指向TensorFlow SavedModel
并指向一个输出目录
而那个输出目录将会在
那些静态的地方
构建artifacts用于网络
Keras也是一样的流程
指向HDF5输入
那么你们有一个输出目录
那些[build artifacts] 会到那里去
现在你们静态地托管在网站某处
只是简单的静态托管
而在JavaScript方面，我们提供
一个可加载那模型的API
这就是TensorFlow的样子

English: 
Let's jump into how
we actually can convert that model.
So, as Daniel mentioned earlier today,
we actually support two types of models,
so we support TensorFlow SavedModels--
we have a converter for that.
And we also have a converter
for Keras SavedModels.
So you define your model
and you save it with a Save model--
this is a standard way to do that.
Similarly, this is a code
that you would do that for Keras
[inaudible].
The next piece is that
we actually convert it to the Web.
Today, we're releasing a pit package.
It's TensorFlow.js,
you can install that there.
There's a script in there
that lets you point
to your TensorFlow SavedModel,
and point to an output directory,
and that output directory
will be where those static
build artifacts will go for the web.
Keras is the same exact flow.
Point to you HDF5 input
and you have an output directory
where those [build artifacts] will go.
Now you statically host those
on your website somewhere,
you know, just simple static hosting.
And on the JavaScript side, we provide
an API that lets you load that model.
So this is what it looks like
for a TensorFlow.

English: 
In the TensorFlow SavedModel
you'll notice that it's a frozen model,
we don't right now support
continuing training of this model.
While in the Keras case,
we actually let you continue training,
and we're working hard to keep
these APIs aligned in the future.
Okay, so under the cover,
what are we actually doing?
So we're doing some graph optimization,
which essentially means
that we prune out nodes
that you don't need
to make the prediction,
you don't need that on the web.
We optimize waits
for browser autocaching,
so we pack in shard in chunks of 4MB
which helps your browser be quick
the next time your page loads.
Today, we support about 90
of the most commonly-used TensorFlow ops,
and we're working very hard
to support more, like control flow ops.
And we support 32
of the most commonly-used
Keras layers today.
And as I mentioned, we let
you continue training for Keras models,
and we let you do evaluation,
as well as make predictions
from that model.
Okay, so obviously,
there's a lot you can do,

Chinese: 
在TensorFlow SavedModel中
你们会注意到这是frozen模型
我们现在不支持
这个模式的持续训练
在Keras例子
事实上我们让你持续训练
我们正在努力将这些API
在未来保持一致
好吧，在隐蔽处
我们究竟在做什么？
我们正在做一些图象优化
这基本上意味着
我们删除节点
你们不需要做预测的
亦不需要在网络上
我们优化等待浏览器自动缓存
我们包装碎片为4MB大小
有助于浏览器在下次
页面加载时加快速度
今天我们支持大约90种
最常用的TensorFlow ops
我们正在努力工作以支持更多
例如control flow ops.
我们支持
32种今天最常用的Keras layers
正如之前提到的我们会继续
让你们训练Keras模型
让你们做评估
并从那个模型做预测
好吧，显然地你们
可以做很多事情

Chinese: 
只需将模型移到Web上进行推论
但自从deeplearn.js开始
我们将其列为重中之重
确保你们可以直接
在浏览器中进行训练
为教育和交互式工具打开了大门
正如Playgroud一样
以及让你们使用数据进行训练
但数据不会离开客户端
这对隐私来说是很重要的
当你们炫耀能夠做一些这样的东西时
我们已经创建了另一个小游戏
这个游戏的目标是
使用摄像头玩Pac-Man
现在Daniel将成为我的助手
出于某些原因
他玩这游戏比我好多了
只是打个招呼
这个游戏有三个阶段
阶段1--我们要
从网络摄像头收集帧
我们要把这些
上，下，左，右联系起来
这些类別
现在Daniel要把他的头
向上，向下，向左，向右移
他只须这样玩游戏
你们会注意到
当他收集帧时
他会稍微移动一下
这种帮助使模型
看到类別的不同角度

English: 
with just porting your models
to the web for inference.
But since the beginning of deeplearn.js,
we've made it a high priority
to make sure that you can
train directly in the browser.
This opens up the door for education
and interactive tools
like we saw with the playground,
as well as let you train with data
that never leaves your client.
So this is huge for privacy.
So you show off what you can do
with something like this,
we've built another little game.
So, the goal of the game
is to play Pac-Man with your webcam.
Now, Daniel's going to be my helper here.
He is much, much better at this game
than I am for some reason.
Just say, "Hi!"
So, there are three phases of the game.
Phase 1-- we're going
to collect frames from the webcam
and we're going to associate those
with up, down, left, and right,
these classes.
Now Daniel's going to move
his head up, down, left, and right,
and he's just simply going
to play the game like that.
And you'll notice,
as he's collecting frames,
he's kind of moving around a little bit.
This kind of helps the model
see different angles for that class

English: 
and generalize a little bit better.
So after he's done
collecting these frames,
we're going to go and train our model.
So we're not actually training
from scratch here
when we hit that Train button.
We're taking a pretrained MobileNet again,
porting that to the web,
and doing a retraining phase
with that data that's local,
and we're using the Layers API
to do that in a browser here.
Do you want to press that Train button?
Alright. Our loss is going down--
looks like we're learning something.
That's great.
So, as soon as we press that Play button,
what's going to happen is we're going
to make predictions from the webcam--
those are going to get plugged
into those controls
and it's going to control
the Pac-Man game.
Ready?
Alright, so you can see
in the bottom right,
it's highlighting the class
that it thinks it is.
And Daniel, if he moves his head around,
you'll see it change [by] class.
And he's off.
(laughter)

Chinese: 
并综合得好一点
在他完成收集这些帧之后
我们要去训练我们的模型
当我们点击那Train按钮时
实际上并没有从头开始训练
我们再次采用预训练的MobileNet
将其移植到网络
并进行再训练阶段
与这些局部数据一起
在这里浏览器中
我们正在使用Layers API这样做
你们想点击那Train按钮Train吗?
好的。我们的损失正在下降
看来我们正在学习一些东西
真的很棒
只要按下那Play 按钮
接下来会发生的事就是
从网络摄像头做预测
那些预测将被插入控制
就会控制Pac-Man 游戏
准备好？
好吧，你们可以看看右下角
明亮部分就是它认为是类别的地方
而当Daniel移动他的头部时
你会看到类别的改变
他离开了

Chinese: 
这些代码都是在线的
你们可以去分割它 -
我们邀请你们这样做
显然这只是一个游戏
你们可以想象这个应用的其他类別
比如做一个浏览器扩展
让你们便于使用易于控制页面
再一次，所有这些代码都是在线的
请去进行Fork，玩玩
并用它做其他事情
- 好吧，Daniel。我知道这很有趣
- 我得走了？好吧
我们必须继续演讲
好的，让我们来谈谈表现
在这里我们看到的是
MobileNet 1.0的基准
用TensorFlow运行
这是TensorFlow classic
没有TensorFlow.js
我想在这里指出
我们使用的批量大小为1
这个很重要
因为我们正在交互式
应用程序的背景下考虑
或者这个Pac-Man 游戏
你们在网络摄像机数据中提供的内容
你们要知道1的预测时间
事实上你们不能真正地进行批量

English: 
So... (chuckling)
all of this code is online,
and you can go fork it--
we invite you to do so.
And obviously, this is just a game.
But you can imagine other types
of applications of this,
like make a browser extension
that lets you control the page
for accessibility purposes.
So again, all this code is online.
Please go fork it, and play
and make something else with it.
- Okay, Daniel. I know this is fun.
- (Daniel) I gotta? Alright.
(laughter) (applause)
You've got to get back to the talk.
Okay, so let's talk a little bit
about performance.
So what we're looking at here
is a benchmark of MobileNet 1.0
running with TensorFlow--
this is TensorFlow classic,
not with TensorFlow.js.
I want to point out here,
we're using a batch size of 1.
This is important
because we're thinking about this
in the context
of an interactive application,
so maybe this Pac-Man game
where you feed in webcam data,
you want to know
what the prediction time is for 1.
You can't really batch things.

English: 
On the top row, we're looking
at TensorFlow CUDA
running on a 1080GTX--
this is a beefy machine.
It's about three milliseconds.
I want to point out--
the shorter the bar,
the faster it is, clearly.
On the second row we have TensorFlow CPU,
and this is running with AVX-512,
and this is on actually
one of these MacBook Pros here.
It's about 60 milliseconds for that frame.
Where does TensorFlow.js
fit into this picture?
Well, it depends.
If you're running on a beefy 1080GTX,
we're actually getting
about 11 milliseconds
for one pass through this MobileNet model,
which is pretty good
if you think about this
in the context of an interactive game.
So, on the laptop that we just
showed the game with,
we're getting about 100 milliseconds
for that inference,
passed through MobileNet.
That's still pretty good.
You can build a whole interactive game
with something that's running
at 100 milliseconds.
So the web is only going to get
faster and faster.
There's a whole new set
of standards coming, like WebGPU,

Chinese: 
在第一排，我们看到
TensorFlow CUDA
在1080GTX上运行
这是一台强大的机器
只有大约三毫秒
我想指出
显然条状物越短速度越快
在第二行我们有 TensorFlow CPU
这是用AVX-512运行的
实际上这是MacBook Pros之一
这个帧大概是60毫秒
TensorFlow.js怎样融入这幅照片?
这得看情况
如果在强大的1080GTX上运行
实际上只需大约11毫秒
就通过这个MobileNet模型
如果你在互动游戏的背景下考虑
这很不错
在我们刚刚展示
这款游戏的笔记本电脑上
这个推论通过MobileNet
运行了大约100毫秒
这很不错
你们可以在运行100毫秒的机器上
建立一个完整的互动游戏
网络只会越来越快
且一套全新的标准即将到来
比如WebGPU

English: 
that will really push the boundary
for these kinds of things.
But the browser still has its limitations.
You can only really get access
to the GPU through WebGL on these APIs.
So, how do we scale beyond that?
How do we scale beyond the limitations
that we have in the browser?
There's a whole ecosystem
of server-side JavaScript tools
using node.js that we would love
to take advantage of.
So today, I'm really happy to tell you
that we're working on node.js bindings
to the TensorFlow C API.
What that means is you'll be able to write
that same low-level ops API
with the Eager mode
we saw with the polynomial example,
or the high-level Layers API
which we saw for the Pac-Man example,
and bind to TensorFlow C,
and run head lists in your TensorFlow
running with CUDA installed.
Eventually, that also means we can run
with a TPU on a backend--
that same JS code.
So these bindings
are underactive developments,

Chinese: 
对于这些东西
这将真的挑战极限
但浏览器仍然有其局限性
你们只能通过这些API上的
WebGL真正地访问GPU
那么我们如何扩大规模？
我们如何突破浏览器的限制？
有一个整个生态系统
在服务端使用node.jsJavaScript工具
而我们乐于利用
今天我很高兴告诉你们
我们正在处理
node.js与TensorFlow C API的绑定
这意味着你们能夠撰写
相同的低层次ops API
与Eager模式
我们用多项式的例子看到
或在Pac-Man的例子中
看到的高层次Layers API
并绑定到TensorFlow C
并在安装CUDA的情况下
在TensorFlow的头列表运行
最终这也意味着
我们可以在后端使用TPU 运行-
使用相同的JS代码
这些绑定没有积极发展

English: 
so stay tuned for more.
Alright, so let's recap some of the things
that we launched today
and that we talked about.
So we talked about this low-level ops API
which does hardware-
accelerated linear algebra
as well as the Eager mode
differentiation for autograd.
This was previously known as deeplearn.js.
We're re-branding that today.
We released the high-level Layers API.
This is the Keras-inspired API
that mirrors TensorFlow Layers,
and we saw an example
of that with the addition RNN,
and we saw an example of that
with the Pac-Man demo.
We also showed you how you can import
TensorFlow SavedModels,
and Keras models for prediction
and retraining in the browser.
We also have released a bunch of demos
and examples on Github.
These are not the only two--
there's a whole repository
of different examples
that can get you started,
and they'll have live links
so you can go and poke around and play.
So I invite you to go do that.

Chinese: 
请继续关注更新
好吧，让我们回顾一些
今天我们谈到
并且是新推出的东西
我们谈到了低级别的ops API
它用于硬件加速的线性代数
以及Eager模式autograd分化
这以前称为 deeplearn.js
我们今天重新塑造这品牌
我们亦发布了高层次 API
这是由Keras启发的API
这反映了TensorFlow Layers
我们看到加上RNN的例子
也看到了Pac-Man的演示
我们还展示了如何导入
TensorFlow SavedModels
和Keras模型进行预测
在浏览器中进行再训练
我们也发布了Github上的
演示和例子
这并不是唯一的两个
有一个不同例子的完整存储库
可以让你们开始
还有实时的链接
你们可以去闲逛并玩一下。
我邀请你们去

Chinese: 
我们真的想看到你们参与这个项目
这里有一堆链接
我们的官方网站是js.tensorflow.org
所有链接我们谈论过的內容都在那里
教程，文件等
我们的代码显然是开源式
tensorflow/tfjs
我邀请你们去那里玩
今天我们也开始了社区邮件名单--
这里是那条链接
社区邮件名单为了开发人员
能夠发布演示和提问以及进行这类事情
这个项目不仅是丹尼尔和我自己
这是更广大的团队努力
我们之间的许多很棒的Google同事
我们要感谢他们
我们也要感谢
所有很棒的deeplearn.js
开源项目贡献者
我们真的兴奋能夠与你们一起
构建机器学习
和JavaScript的下一章
- 谢谢大家
- 谢谢

English: 
So we really want
to see you get involved in this project.
We have a bunch of links here,
so js.tensorflow.org
is our official website.
All of these links,
everything we've talked about is there--
there's tutorials,
there's documentation, etc.
Our code is obviously open-sourced
under tensorflow/tfjs.
So I invite you to go play there too.
And we also started
a community mailing list today--
that's the short link here.
And the community
mailing list is for people
to post demos and ask questions,
and that kind of thing.
So this project
was not just Daniel and myself,
this was a larger team effort
between many of our amazing
colleagues at Google.
So we want to thank them.
We also want to thank
all of the amazing open-source
contributors for deeplearn.js.
And we're really excited
to build the next chapter
of machine learning
and JavaScript with you.
- Thank you
- (Daniel) Thank you.
(applause)
♪ (music) ♪
