text: #
  # A simple multi-layer feedforward neural network to solve the XOR problem.
  # https://classroom.udacity.com/nanodegrees/nd889/parts/16cf5df5-73f0-4afa-93a9-de5974257236/modules/6124bd95-dec2-44f9-bf3b-498ea57699c7/lessons/47f6c25c-7749-4a02-b807-7a5b37f362e8/concepts/7c3d9b4c-206d-4430-9459-c78357181d9a
  #
  import numpy as np
  from keras.utils import np_utils
  import tensorflow as tf
  tf.python.control_flow_ops = tf
  
  # Set random seed
  np.random.seed(42)
  
  # Our data
  X = np.array([[0,0],[0,1],[1,0],[1,1]]).astype('float32')
  y = np.array([[0],[1],[1],[0]]).astype('float32')
  
  # Initial Setup for Keras
  from keras.models import Sequential
  from keras.layers.core import Dense, Activation, Flatten
  
  # One-hot encoding the output
  y = np_utils.to_categorical(y)
  
  # Building the model
  xor = Sequential()
  xor.add(Dense(32, input_dim=2))
  xor.add(Activation("sigmoid"))
  xor.add(Dense(2))
  xor.add(Activation("sigmoid"))
  
  xor.compile(loss="categorical_crossentropy", optimizer="adam", metrics = ['accuracy'])
  
  # Uncomment this line to print the model architecture
  xor.summary()
  
  # Fitting the model
  history = xor.fit(X, y, nb_epoch=1000, verbose=0)
  
  # Scoring the model
  score = xor.evaluate(X, y)
  print("\nAccuracy: ", score[-1])
  
  # Checking the predictions
  print("\nPredictions:")
  print(xor.predict_proba(X))
  