TensorFlow Introduction_中英文對(duì)照

文章作者:Tyan
博客:noahsnail.com ?|? CSDN ?|? 簡(jiǎn)書

Introduction

Let's get you up and running with TensorFlow!

讓我們開(kāi)始學(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.

但在我們開(kāi)始之前,讓我們先看一眼在Python API中TensorFlow代碼什么樣,對(duì)我們要學(xué)習(xí)的東西有點(diǎn)感覺(jué)。

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

下面是一個(gè)Python小程序,它在二維空間構(gòu)造了一些數(shù)據(jù),并用一條直線來(lái)擬合這些數(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才開(kāi)始真正的進(jìn)行計(jì)算。

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í)問(wèn)題是什么樣子。在神經(jīng)網(wǎng)絡(luò)領(lǐng)域,最經(jīng)典的問(wèn)題是MNIST手寫字符識(shí)別問(wèn)題。這兒我們有兩個(gè)介紹,一個(gè)是為初學(xué)者準(zhǔn)備的,一個(gè)是為專業(yè)人士準(zhǔn)備的。如果你已經(jīng)用其它的軟件包訓(xùn)練了許多MNIST模型,請(qǐng)點(diǎn)紅色的藥丸。如果你從未聽(tīng)過(guò)MNIST,請(qǐng)點(diǎn)藍(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,你可以跳過(guò)這些直接看接下來(lái)的東西。不用擔(dān)心,你仍會(huì)看到MNIST——我們也將使用MNIST作為技術(shù)教程中的一個(gè)例子來(lái)闡述TensorFlow的特性。

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

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

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

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