Skip to content

Commit 28dd80b

Browse files
authored
Merge pull request jikexueyuanwiki#185 from jiahui-qin/master
use tf.global_variables_initializer() instead tf.initialize_all_variables()
2 parents 19b927c + 67b0ab9 commit 28dd80b

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

tex_pdf/get_started/c1s01_introduction.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ \section{Introduction || 简介}
4141
train = optimizer.minimize(loss)
4242

4343
# Before starting, initialize the variables. We will 'run' this first.
44-
init = tf.initialize_all_variables()
44+
init = tf.global_variables_initializer()
4545

4646
# Launch the graph.
4747
sess = tf.Session()

tex_pdf/get_started/c1s03_basic_usage.tex

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ \subsection{Interactive Usage | 交互式使用}
201201
x.initializer.run()
202202

203203
# Add an op to subtract 'a' from 'x'. Run it and print the result
204-
sub = tf.sub(x, a)
204+
sub = tf.subtract(x, a)
205205
print(sub.eval())
206206
# ==> [-2. -1.]
207207

@@ -239,7 +239,7 @@ \subsection{Variables | 变量}
239239

240240
# Variables must be initialized by running an `init` Op after having
241241
# launched the graph. We first have to add the `init` Op to the graph.
242-
init_op = tf.initialize_all_variables()
242+
init_op = tf.global_variables_initializer()
243243

244244
# Launch the graph and run the ops.
245245
with tf.Session() as sess:
@@ -282,7 +282,7 @@ \subsection{Fetches | 取回}
282282
input2 = tf.constant(2.0)
283283
input3 = tf.constant(5.0)
284284
intermed = tf.add(input2, input3)
285-
mul = tf.mul(input1, intermed)
285+
mul = tf.multiply(input1, intermed)
286286

287287
with tf.Session() as sess:
288288
result = sess.run([mul, intermed])
@@ -311,7 +311,7 @@ \subsection{Feeds | 供给}
311311
\begin{lstlisting}
312312
input1 = tf.placeholder(tf.float32)
313313
input2 = tf.placeholder(tf.float32)
314-
output = tf.mul(input1, input2)
314+
output = tf.multiply(input1, input2)
315315

316316
with tf.Session() as sess:
317317
print(sess.run([output], feed_dict={input1:[7.], input2:[2.]}))

0 commit comments

Comments
 (0)