August 2018
Intermediate to advanced
272 pages
7h 2m
English
Here, we put together some of the things we have learned about so far and will solve the Boolean XOR problem with TensorFlow. In this example, we are going to create a three-layer neural network with sigmoid activation functions. We use log loss as there is only two possible outcomes for out network 0 or 1:
import tensorflow as tf # XOR dataset XOR_X = [[0, 0], [0, 1], [1, 0], [1, 1]] XOR_Y = [[0], [1], [1], [0]] num_input = 2 num_classes = 1 # Define model I/O (Placeholders are used to send/get information from graph) x_ = tf.placeholder("float", shape=[None, num_input], name='X') y_ = tf.placeholder("float", shape=[None, num_classes], name='Y') # Model structure H1 = tf.layers.dense(inputs=x_, units=4, ...