上QQ阅读APP看书,第一时间看更新
Running the session
The last step is to run the architecture that has just been designed. The thinking was done in the previous steps.
To run the program, the minimum code is for opening a session and running iterations, as shown in the following code snippet:
#II.data
XOR_X = [[0,0],[0,1],[1,0],[1,1]]
XOR_Y = [[0],[1],[1],[0]]
#III.data flow graph computation
init = tf.global_variables_initializer()
sess = tf.Session()
sess.run(init)
for epoch in range(50000):
sess.run(train_step, feed_dict={x_: XOR_X, y_: XOR_Y})
Feeding the data into the data flow graph is done with feed_dict. Feed is a keyword in FNN. This is an important feature. It is possible to feed parts of a dataset, not all of the data in stochastic (picking only parts of the dataset to train) gradient descent models as explained in Chapter 6, Don't Get Lost in Techniques – Focus on Optimizing Your Solutions.