Ex. x=1.2 , 2x mod 1 = 0.4
The question I tried to ask was that does the RNN learn the map after some iterations?
Here is the code for doing the training:
f [x_] := Mod[2*x, 1];
data = NestList[f, 0.1, 100];
n = 1;
training =
RandomSample[
List /@ Most[#] -> List@Last[#] & /@ (Partition[data, n + 1, 1])];
net = NetChain[{GatedRecurrentLayer[40], GatedRecurrentLayer[40],
GatedRecurrentLayer[40], GatedRecurrentLayer[40],
GatedRecurrentLayer[20], GatedRecurrentLayer[20],
GatedRecurrentLayer[20], GatedRecurrentLayer[20], LinearLayer[1]},
"Input" -> {n, 1}, "Output" -> 1]
trained = NetTrain[net, training, TargetDevice -> "CPU"]
trainedmap [x_] := Flatten[Append[Rest[x], trained[x]]];
Here is the plot of the result where predicted is in blue and ground truth in yellow. I gave RNN an initial condition then its output was used over and over again.