您的位置:首页 > 其它

TensorFlow Introduction_中英文对照

2016-10-18 22:41 507 查看
文章作者: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,请点蓝色药丸。如果你介于两者之间,我们建议你先略读蓝色部分,再看红色部分。









图像许可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的特性。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: