-
Notifications
You must be signed in to change notification settings - Fork 842
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Translate Chinese comments to English (#3)
* Translate Chinese comments to English * Translate Chinese comments to English * Translate Chinese comments to English * Translate Chinese comments to English * Translate Chinese comments to English * Translate Chinese comments to English * Translate Chinese comments to English * Update traslation * Update translation * Translate Chinese comments to English * Update traslation * Update translation * Update translation * Update translation * Update translations
- Loading branch information
1 parent
69493cd
commit dd216a1
Showing
8 changed files
with
32 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
import tensorflow as tf | ||
|
||
# 定义一个“计算图” | ||
a = tf.constant(1) # 定义一个常量Tensor(张量) | ||
# Defince a "Computation Graph" | ||
a = tf.constant(1) # Defince a constant Tensor | ||
b = tf.constant(1) | ||
c = a + b # 等价于 c = tf.add(a, b),c是张量a和张量b通过Add这一Operation(操作)所形成的新张量 | ||
c = a + b # Equal to c = tf.add(a, b),c is a new Tensor created by Tensor a and Tesor b's add Operation | ||
|
||
sess = tf.Session() # 实例化一个Session(会话) | ||
c_ = sess.run(c) # 通过Session的run()方法对计算图里的节点(张量)进行实际的计算 | ||
print(c_) | ||
sess = tf.Session() # Initailize a Session | ||
c_ = sess.run(c) # Session的run() will do actually computation to the nodes (Tensor) in the Computation Graph | ||
print(c_) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
import tensorflow as tf | ||
|
||
A = tf.ones(shape=[2, 3]) # tf.ones(shape)定义了一个形状为shape的全1矩阵 | ||
A = tf.ones(shape=[2, 3]) # tf.ones(shape) defines a all one matrix with shape | ||
B = tf.ones(shape=[3, 2]) | ||
C = tf.matmul(A, B) | ||
|
||
sess = tf.Session() | ||
C_ = sess.run(C) | ||
print(C_) | ||
print(C_) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
import tensorflow as tf | ||
|
||
a = tf.placeholder(dtype=tf.int32) # 定义一个占位符Tensor | ||
a = tf.placeholder(dtype=tf.int32) # Define a placeholder Tensor | ||
b = tf.placeholder(dtype=tf.int32) | ||
c = a + b | ||
|
||
a_ = input("a = ") # 从终端读入一个整数并放入变量a_ | ||
a_ = input("a = ") # Read an Integer from terminal and put it into a_ | ||
b_ = input("b = ") | ||
|
||
sess = tf.Session() | ||
c_ = sess.run(c, feed_dict={a: a_, b: b_}) # feed_dict参数传入为了计算c所需要的张量的值 | ||
print("a + b = %d" % c_) | ||
c_ = sess.run(c, feed_dict={a: a_, b: b_}) # feed_dict will input Tensors' value needed by computing c | ||
print("a + b = %d" % c_) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
import tensorflow as tf | ||
|
||
a = tf.get_variable(name='a', shape=[]) | ||
initializer = tf.assign(a, 0) # tf.assign(x, y)返回一个“将张量y的值赋给变量x”的操作 | ||
a_plus_1 = a + 1 # 等价于 a + tf.constant(1) | ||
initializer = tf.assign(a, 0) # tf.assign(x, y) will return a operation “assign Tensor y's value to Tensor x” | ||
a_plus_1 = a + 1 # Equal to a + tf.constant(1) | ||
plus_one_op = tf.assign(a, a_plus_1) | ||
|
||
sess = tf.Session() | ||
sess.run(initializer) | ||
for i in range(5): | ||
sess.run(plus_one_op) # 对变量a执行加一操作 | ||
a_ = sess.run(a) # 获得变量a的值并存入a_ | ||
sess.run(plus_one_op) # Do plus one operation to a | ||
a_ = sess.run(a) # Calculate a‘s value and put the result to a_ | ||
print(a_) |
4 changes: 2 additions & 2 deletions
4
source/_static/code/en/basic/graph/variable_with_initializer.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters