Artificial Neural Networks

Which have been covered in AI/ML course and CV labs, but has not been deeply explored. The idea seems being sexy, but we care more about reality, what it is, how it works, what it can do for us and what can we do for it?

Starting from a 9 lines of 'nn' code piece

Got from wechat, actually its just logistic regression.


In [ ]:
from numpy import exp, array, random, dot
datum = array([0, 0, 1], [1, 1, 1], [1, 0, 1], [0, 1, 1])
label = array([[0, 1, 1, 0]]).T
random.seed(233)
weights = 2 * random.random((3, 1)) - 1 # (-1, 1)

for i in range(1000):
    output = 1 / (1 + exp(-(dot(datum, weights)))) # sigmoid
    weights += dot(datum.T, (label - output) * output * (1 - output))
    
print (1 / (1 + exp(-dot(array([1, 0, 0]), weights)))) # try prediction