前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >TensorFlow Introduction_中英文对照

TensorFlow Introduction_中英文对照

作者头像
Tyan
发布2022-05-09 08:31:57
3160
发布2022-05-09 08:31:57
举报
文章被收录于专栏:SnailTyan

文章作者: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小程序,它在二维空间构造了一些数据,并用一条直线来拟合这些数据。

代码语言:javascript
复制
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的特性。

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2016-10-18,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • Introduction
相关产品与服务
云开发 CloudBase
云开发(Tencent CloudBase,TCB)是腾讯云提供的云原生一体化开发环境和工具平台,为200万+企业和开发者提供高可用、自动弹性扩缩的后端云服务,可用于云端一体化开发多种端应用(小程序、公众号、Web 应用等),避免了应用开发过程中繁琐的服务器搭建及运维,开发者可以专注于业务逻辑的实现,开发门槛更低,效率更高。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档