1
$\begingroup$

I'm new to neural nets, and I'm having a hard time wrapping my head around the concept of weights and whatnot.

I've been staring at a diagram of the XOR neural network for an hour, and I genuinely have no idea what I'm looking at. I just can't figure out how it works.

Can someone explain how the four possible cases work here? I've tried walking through a simple example like (1,1), but I don't even have a basic grasp of how this is supposed to work. I've watch a bunch of tutorials on this, but I'm just totally lost on this simple example. Clearly misunderstanding something, would be awesome to get a simple explanation of how XOR works.

$\endgroup$

1 Answer 1

4
$\begingroup$

No wonder you're struggling, because there's no standard way of visualizing NNs. Everyone does what they can to confuse the beginners.

  • you have two inputs, set both to 1: $x_1=x_2=1$
  • first neuron of the first layer gets these inputs with the weights: $z[1,1] = x_1 + x_2 = 1$
  • "OR": $a[1,1] = ( z[1,1]>0.5 ) = 1$
  • second neuron of the first layer gets these inputs with the weights: $z[1,2] = -x_1 -x_2 = -2$
  • "NOT AND": $a[1,1] = ( z[1,2]>-1.5 ) = 0$
  • neuron of the second layer gets the outputs of first layer with the weights: $z[2,1] = a[1,1] + a[1,2] = 1$
  • "AND": $a[2,1] = ( z[2,1]>1.5 ) = 0$ Do the same for inputs (1,0),(0,0) and (0,1). Voila your XOR!

The values on connectors are weights, and the values in circles are thresholds for perceptrons to fire.

Python code:

for x1 in (0,1):
  for x2 in (0,1):
    a11=(x1+x2)>0.5
    a12=(-x1-x2)>-1.5
    a21 = (a11+a12)>1.5
    print(x1,' xor ',x2,' = ',a21)
$\endgroup$
2
  • 2
    $\begingroup$ "Everyone does what they can to confuse the beginners" $\endgroup$ Commented Feb 14, 2018 at 2:06
  • $\begingroup$ I know this is old, but the second bullet point has x1 + x2 = 1, shouldn't it equal 2? $\endgroup$
    – zapshe
    Commented May 5, 2022 at 3:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.