TensorFlow Introduction_中英文對照

文章作者:Tyan
博客:noahsnail.com ?|? CSDN ?|? 簡書

Introduction

Let's get you up and running with TensorFlow!

讓我們開始學(xué)習(xí)并運(yùn)行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代碼什么樣,對我們要學(xué)習(xí)的東西有點感覺。

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

下面是一個Python小程序,它在二維空間構(gòu)造了一些數(shù)據(jù),并用一條直線來擬合這些數(shù)據(jù)。

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.

代碼的第一部分構(gòu)建數(shù)據(jù)流圖。在session創(chuàng)建和run函數(shù)調(diào)用之后,TensorFlow才開始真正的進(jìn)行計算。

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.

為了進(jìn)一步提高你的興趣,我們建議你查看一下在TensorFlow中經(jīng)典的機(jī)器學(xué)習(xí)問題是什么樣子。在神經(jīng)網(wǎng)絡(luò)領(lǐng)域,最經(jīng)典的問題是MNIST手寫字符識別問題。這兒我們有兩個介紹,一個是為初學(xué)者準(zhǔn)備的,一個是為專業(yè)人士準(zhǔn)備的。如果你已經(jīng)用其它的軟件包訓(xùn)練了許多MNIST模型,請點紅色的藥丸。如果你從未聽過MNIST,請點藍(lán)色藥丸。如果你介于兩者之間,我們建議你先略讀藍(lán)色部分,再看紅色部分。


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.

如果你已經(jīng)確定你想學(xué)習(xí)并安裝TensorFlow,你可以跳過這些直接看接下來的東西。不用擔(dān)心,你仍會看到MNIST——我們也將使用MNIST作為技術(shù)教程中的一個例子來闡述TensorFlow的特性。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • **2014真題Directions:Read the following text. Choose the be...
    又是夜半驚坐起閱讀 11,025評論 0 23
  • 希望世上的流浪動物都能獲得幸福...... 相信一定是Bobby當(dāng)初感謝的動作感動了Muniowski吧!
    哈哈哈哈水洗面膜和閱讀 136評論 0 0
  • “弟弟,你再等等,我這就出去買藥。” “可是,現(xiàn)在出去……” “沒事的?!?我知道,現(xiàn)在出去很不安全。我們這個星球...
    職場解憂鋪何掌柜閱讀 6,667評論 2 3
  • 這次的作品本身有一定的難度,繪畫所需要的時間有點長,而細(xì)節(jié)的處理又需要細(xì)致。一開始覺得是對自己的挑戰(zhàn),克服畏難情緒...
    煙雨程程閱讀 231評論 2 2
  • 這個月的雨水特別多,就連那滿城的桂花,都被沉沉的雨打落了一地,待太陽出來的時候,躺在地上的它們是否清香依然?
    游離的吉普賽人閱讀 166評論 0 0

友情鏈接更多精彩內(nèi)容