Can't get a simple XOR problem network to work, answer always array([0])
See original GitHub issueI am trying to implement a XOR-problem solving network and can’t seem to get it to work. Here’s my code:
model = Sequential()
model.add(Dense(2,2))
model.add(Activation('sigmoid'))
model.add(Dense(2,1))
model.add(Activation('softmax'))
X = numpy.array([[0,0],[0,1],[1,0],[1,1]])
y = numpy.array([[0],[1],[1],[0]])
model.compile(loss='categorical_crossentropy', optimizer='sgd')
model.fit(X, y, nb_epoch=5, batch_size=32)
No matter what input I try, the answer to predict_classes
is always array([0])
, with predict_proba
result always being array([[ 1.]])
.
I have tried other setups, with tanh activation, loss='mean_absolute_error'
, optimizer='rmsprop'
, nb_epoch=20, batch_size=16
, but there was no difference.
Issue Analytics
- State:
- Created 8 years ago
- Comments:22 (6 by maintainers)
Top Results From Across the Web
Understanding Basics of Deep Learning by solving XOR ...
In our X-OR problem, output is either 0 or 1 for each input sample. So, it is a two class or binary classification...
Read more >My Neural Network Doesn't Work [XOR problem]
I'm trying to make a neural network for solving XOR problem.But I couldn't make it.Always giving false results.Maybe I'm making a mistake in ......
Read more >Is it normal that a Neural Network sometimes doesn't learn Xor?
I've implemented a neural network and I'm training it to compute Xor. 1 out of x times it fails to learn, where x...
Read more >How Neural Networks Solve the XOR Problem
The XOR functionAttempt #1: The Single Layer Perceptron ... in the case of a simple classifier, an output of say -2.5 or 8...
Read more >#006 PyTorch - Solving the famous XOR problem using Linear ...
Highlights: One of the most historical problems in the Neural Network arena is the classic XOR problem where predicting the output of the ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
If I weren’t interested in learning how to use Keras, I wouldn’t have raised this issue. If you don’t have the time to help, then you shouldn’t spend it writing a passive-aggressive retort either.
Here’s an XOR net that works with the new API: