I'm trying to implement a model of a recurrent neural network to solve a temporal version of the XOR problem, but I am not still able to do that. Any hints?
Asked
Active
Viewed 1,140 times
2 Answers
0
I think following this link helps you, I have gone trough those tutorials previously. Also take a look at this tutorial .

Green Falcon
- 14,058
- 9
- 57
- 98

Sampath Madala
- 157
- 1
- 7
-
Thank you. They are very useful. I use them. I forget to add in my question that I need to use recurrent neural networks – Cecilia Feb 21 '18 at 15:53
-
0
Use the following code:
import keras
import numpy as np
a = np.array([[1, 1], [0, 1], [1, 0], [0, 0]])
b = np.array([[0], [1], [1], [0]])
model = keras.Sequential()
model.add(keras.layers.Dense(2, activation = 'sigmoid', input_shape = (2, )))
model.add(keras.layers.Dense(1, activation = 'sigmoid'))
model.compile(optimizer = keras.optimizers.rmsprop(), metrics = ['accuracy'], loss = 'binary_crossentropy')
model.fit(x = a, y = b, epochs = 750)
If you don't get 100%
accuracy increase the number of epochs. Also take a look at here which may help you how increasing the size of each layer affects the learning process.

Green Falcon
- 14,058
- 9
- 57
- 98
-
Thank you. I used that example. I forget to add in the question that I need to use recurrent networks. I try to do this: https://github.com/katejarne/xor_recurrent_test but I cant make my code works: – Cecilia Feb 21 '18 at 15:54
-
1I solved the problem a couple of years ago. I implemented such a function. I forgot that I have posted the question and published 2 papers on Computational neuroscience. Here are the links to the paper, each of them has the repository: https://doi.org/10.1007/s11571-022-09802-5 and https://iopscience.iop.org/article/10.1088/2632-072X/abdee3 Also on my GitHub is more: https://github.com/katejarne/RRN_dynamics – Cecilia Nov 22 '22 at 11:29
-
@Cecilia sorry for my late late response. I'm really happy that finally you did it :) – Green Falcon Dec 02 '22 at 10:27
MLPs
.XOR
does not have any temporal behavior at least as far as I know. – Green Falcon Feb 21 '18 at 13:16