Problems training my model

I am learning about timeline forecasting. I just made a synthetic data to try a simple model with this code:

x = np.array([serie5[i:i+20] for i in range(979)])[…,np.newaxis]
y = np.array([serie5[i+1:i+21] for i in range(979)])[…,np.newaxis]
model = tf.keras.Sequential([
tf.keras.layers.Dense(34),
tf.keras.layers.Dense(1)
])
op = tf.keras.optimizers.Adam()
ls = tf.keras.losses.MeanSquaredError()
model.compile(op,
ls)
model.fit(x,y)

the problem here is that the model learns to predict exactly the same input data, but not the output which is a same lenght windows one step to the right, what is wrong with the code?

Hi @Miguel_Augusto_Melo ,

Welcome to the TF Forum!

The problem I can see is that the target sequence should start with 21. You need to change the target y to be the sequence shifted one step to the right, instead of being the same as the input sequence.

Here is the modified code:

x = np.array([serie5[i:i+20] for i in range(979)])[…,np.newaxis]
y = np.array([serie5[i+21:i+41] for i in range(979)])[…,np.newaxis]

Please refer to this documentation for Data windowing

Please let me know if it helps you.

Thanks.