Just for comparison this is almost the same using a library [1]:
import numpy as np
X = np.array([ [0,0,1],[0,1,1],[1,0,1],[1,1,1]])
y = np.array([[0,0,1,1]]).T
from keras.models import Sequential
from keras.layers.core import Dense
model = Sequential([Dense(3, 1, init='uniform', activation='sigmoid')])
model.compile(loss='mean_absolute_error', optimizer='sgd')
model.fit(X, y, nb_epoch=10000)
model.predict(X)
[1] http://keras.io