@@ -201,7 +201,7 @@ \subsection{Interactive Usage | 交互式使用}
201
201
x.initializer.run()
202
202
203
203
# 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)
205
205
print(sub.eval())
206
206
# ==> [-2. -1.]
207
207
@@ -239,7 +239,7 @@ \subsection{Variables | 变量}
239
239
240
240
# Variables must be initialized by running an `init` Op after having
241
241
# 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 ()
243
243
244
244
# Launch the graph and run the ops.
245
245
with tf.Session() as sess:
@@ -282,7 +282,7 @@ \subsection{Fetches | 取回}
282
282
input2 = tf.constant(2.0)
283
283
input3 = tf.constant(5.0)
284
284
intermed = tf.add(input2, input3)
285
- mul = tf.mul (input1, intermed)
285
+ mul = tf.multiply (input1, intermed)
286
286
287
287
with tf.Session() as sess:
288
288
result = sess.run([mul, intermed])
@@ -311,7 +311,7 @@ \subsection{Feeds | 供给}
311
311
\ begin{lstlisting}
312
312
input1 = tf.placeholder(tf.float32)
313
313
input2 = tf.placeholder(tf.float32)
314
- output = tf.mul (input1, input2)
314
+ output = tf.multiply (input1, input2)
315
315
316
316
with tf.Session() as sess:
317
317
print(sess.run([output], feed_dict={input1:[7.], input2:[2.]}))
0 commit comments