<jupyter_start><jupyter_text>Training Examples All combinations of XOR for 3 inputs<jupyter_code>X = [[0,0,0],[0,0,1], [0,1,0], [0,1,1], [1,0,0], [1,0,1],[1,1,0], [1,1,1]]
Y = [[0], [1], [1], [0], [1], [0], [0], [1]]
### Neural Network Parameters
N_STEPS = 200000
N_EPOCH = 100000
N_TRAINING = len(X)

N_INPUT_NODES = 3
N_HIDDEN_NODES = 7
N_OUTPUT_NODES = 1

ACTIVATION = 'tanh'
COST = 'MSE'
LEARNING_RATE = 0.05
## Placeholders for all variables

x_ = tf.placeholder(tf.float32, shape=[None, N_INPUT_NODES], name="x-input")
y_ = tf.placeholder(tf.float32, shape=[N_TRAINING, N_OUTPUT_NODES], name="y-input")

theta1 = tf.Variable(tf.random_uniform([N_INPUT_NODES, N_HIDDEN_NODES], -1, 1), name="theta1")
theta2 = tf.Variable(tf.random_uniform([N_HIDDEN_NODES, N_OUTPUT_NODES], -1, 1), name="theta2")

bias1 = tf.Variable(tf.zeros([N_HIDDEN_NODES]), name="bias1")
bias2 = tf.Variable(tf.zeros([N_OUTPUT_NODES]), name="bias2")
layer1 = tf.sigmoid(tf.matmul(x_, theta1) + bias1)
output = tf.sigmoid(tf.matmul(layer1, theta2) + bias2)

cost = tf.reduce_mean(tf.square(Y-output))
train_step = tf.train.GradientDescentOptimizer(LEARNING_RATE).minimize(cost)
init = tf.initialize_all_variables()
sess = tf.Session()
sess.run(init)
for i in range(N_STEPS):
    sess.run(train_step, feed_dict={x_ : X, y_: Y})
    if i % N_EPOCH == 0:
        print('Batch', i)
        print('Inference', sess.run(output, feed_dict={x_ : X, y_:Y}))
        print('Cost', sess.run(cost, feed_dict={x_: X, y_:Y}))
print('Prediction', sess.run(output, feed_dict={x_ : [[0,1,0]]}))
print('Prediction', sess.run(output, feed_dict={x_ : [[1,0.9,0.8]]}))
print('Prediction', sess.run(output, feed_dict={x_ : [[0.2,1.4,0.1]]}))
print('Prediction', sess.run(output, feed_dict={x_ : [[1.9,1.4,0.1]]}))
print('Prediction', sess.run(output, feed_dict={x_ : [[1.9,-1.4,0.1]]}))<jupyter_output>('Prediction', array([[ 0.37569797]], dtype=float32))
{'fraction_non_alphanumeric': 0.21226415094339623, 'fraction_numerical': 0.05817610062893082, 'mean_word_length': 6.149812734082397, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '559186', 'license': 'MIT', 'n_tokens_mistral': 876, 'n_tokens_neox': 832, 'n_words': 142, 'path': 'tensorflow/3-input-XOR/3-input-XOR.ipynb', 'repo_name': 'tanaypratap/learning-deep-learning', 'size': '1908'}