TensorFlow Introduction_中英文对照

文章作者:Tyan
博客:noahsnail.com  |  CSDN  |  简书

Introduction

Let's get you up and running with TensorFlow!

让我们开始学习并运行TensorFlow!

But before we even get started, let's peek at what TensorFlow code looks like in the Python API, so you have a sense of where we're headed.

但在我们开始之前,让我们先看一眼在Python API中TensorFlow代码什么样,对我们要学习的东西有点感觉。

Here's a little Python program that makes up some data in two dimensions, and then fits a line to it.

下面是一个Python小程序,它在二维空间构造了一些数据,并用一条直线来拟合这些数据。

import tensorflow as tf
import numpy as np

# Create 100 phony x, y data points in NumPy, y = x * 0.1 + 0.3
x_data = np.random.rand(100).astype(np.float32)
y_data = x_data * 0.1 + 0.3

# Try to find values for W and b that compute y_data = W * x_data + b
# (We know that W should be 0.1 and b 0.3, but TensorFlow will
# figure that out for us.)
W = tf.Variable(tf.random_uniform([1], -1.0, 1.0))
b = tf.Variable(tf.zeros([1]))
y = W * x_data + b

# Minimize the mean squared errors.
loss = tf.reduce_mean(tf.square(y - y_data))
optimizer = tf.train.GradientDescentOptimizer(0.5)
train = optimizer.minimize(loss)

# Before starting, initialize the variables.  We will 'run' this first.
init = tf.initialize_all_variables()

# Launch the graph.
sess = tf.Session()
sess.run(init)

# Fit the line.
for step in range(201):
    sess.run(train)
    if step % 20 == 0:
        print(step, sess.run(W), sess.run(b))

# Learns best fit is W: [0.1], b: [0.3]

The first part of this code builds the data flow graph. TensorFlow does not actually run any computation until the session is created and the run function is called.

代码的第一部分构建数据流图。在session创建和run函数调用之后,TensorFlow才开始真正的进行计算。

To whet your appetite further, we suggest you check out what a classical machine learning problem looks like in TensorFlow. In the land of neural networks the most "classic" classical problem is the MNIST handwritten digit classification. We offer two introductions here, one for machine learning newbies, and one for pros. If you've already trained dozens of MNIST models in other software packages, please take the red pill. If you've never even heard of MNIST, definitely take the blue pill. If you're somewhere in between, we suggest skimming blue, then red.

为了进一步提高你的兴趣,我们建议你查看一下在TensorFlow中经典的机器学习问题是什么样子。在神经网络领域,最经典的问题是MNIST手写字符识别问题。这儿我们有两个介绍,一个是为初学者准备的,一个是为专业人士准备的。如果你已经用其它的软件包训练了许多MNIST模型,请点红色的药丸。如果你从未听过MNIST,请点蓝色药丸。如果你介于两者之间,我们建议你先略读蓝色部分,再看红色部分。


image

图像许可CC BY-SA 4.0; 原作者W. Carter

If you're already sure you want to learn and install TensorFlow you can skip these and charge ahead. Don't worry, you'll still get to see MNIST -- we'll also use MNIST as an example in our technical tutorial where we elaborate on TensorFlow features.

如果你已经确定你想学习并安装TensorFlow,你可以跳过这些直接看接下来的东西。不用担心,你仍会看到MNIST——我们也将使用MNIST作为技术教程中的一个例子来阐述TensorFlow的特性。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • **2014真题Directions:Read the following text. Choose the be...
    又是夜半惊坐起阅读 13,516评论 0 23
  • 希望世上的流浪动物都能获得幸福...... 相信一定是Bobby当初感谢的动作感动了Muniowski吧!
    哈哈哈哈水洗面膜和阅读 1,144评论 0 0
  • “弟弟,你再等等,我这就出去买药。” “可是,现在出去……” “没事的。” 我知道,现在出去很不安全。我们这个星球...
    职场解忧铺何掌柜阅读 11,599评论 2 3
  • 这次的作品本身有一定的难度,绘画所需要的时间有点长,而细节的处理又需要细致。一开始觉得是对自己的挑战,克服畏难情绪...
    烟雨程程阅读 1,508评论 2 2
  • 这个月的雨水特别多,就连那满城的桂花,都被沉沉的雨打落了一地,待太阳出来的时候,躺在地上的它们是否清香依然?
    游离的吉普赛人阅读 1,256评论 0 0

友情链接更多精彩内容