Skip to content

Instantly share code, notes, and snippets.

@pyradd
pyradd / nn2.py
Created May 30, 2018 10:55 — forked from vinupriyesh/nn2.py
Simple neural network to predict XOR gate in python
"""
A simple neural network with 1 hidden layer and 4 neurons, an enhancement to the previous logistic regression to compute the XOR
@Author : Vinu Priyesh V.A.
"""
import numpy as np
#Compute functions for OR, AND, XOR, this will be used to generate the test set and to validate our results
def compute(x,m,label):
if(label == "XOR"):
return np.logical_xor(x[0,:],x[1,:]).reshape(1,m).astype(int)