The target
This article is intended to introduce the introduction of TensorFlow and practical examples. We hope that you will become familiar with the operation of TensorFlow after learning it
Simple variable manipulation
Import tensorflow as tf x = tf.variable ([9,10]) y = tf.constant([4,4]) sub = tf.subtract(x, y) add = tf.add(x, subtract) Y) init = tf.global_variables_initializer() # init = tf.session () sess.run(init) print(sess.run([sub, add]))Copy the code
The output
[array([5, 6], dtype=int32), array([13, 14], dtype=int32)]
Copy the code
Progressive – variable increment
import tensorflow as tf state = tf.Variable(0, name='state') add = tf.add(state, Update = tf.assign(state, Init = tf.global_variables_initializer() with tf.session () as sess: Sess.run (init) print(sess.run(state)) print(sess.run(state)) Sess.run (update) # print(sess.run(state)) # print(sess.run(state)) # print(sess.run(state)) # print(sess.run(state)Copy the code
The output
0
2
4
6
Copy the code
In this paper, the reference
Reference for this article: blog.csdn.net/qq_19672707…