Hand designed sigmoid function to out put 0,1 if x<0.5.
I had to manually design a activation function to do this because this cannot be done simply by if x>0.5 return 1 else return 0 like you have done in your code. The back propagation breaks.