I am trying to predict a sequence of integers based on the input numbers.
The input consists of values with 10 integers:
array([[2021001001], [2021001002],...,
,[2021335249]],dtype=int64)
The output is the following, an array containing 7 integers.
array([[23, 26, 17, ..., 21, 16, 4],
[13, 24, 2, ..., 27, 10, 28],
...,
[ 5, 16, 28, ..., 12, 27, 26]], dtype=int64)
This means that sequence number (input) [2021001001] will return the following sequence (output) [23, 26, 17, ..., 21, 16, 4].
I tried training an LSTM on these inputs and outputs to predict what the following sequence will be based on a sequence number. I'm using about +60K of historical data to do this. So far here's what I did:
model = tf.keras.Sequential()
model.add(layers.LSTM(256, activation='relu', input_shape=(10, 1), recurrent_dropout=0.2))
model.add(layers.Dense(7))
model.compile(optimizer=tf.keras.optimizers.Adam(0.00001), loss=tf.keras.losses.MeanSquaredError(), metrics=['accuracy'])
model.fit(inputs, output, epochs=10, verbose=1, validation_split=0.2, batch_size=256)
When testing the model after fitting we get weird results like the following:
predictNextNumber = model.predict(tests_[0], verbose=1)
print(predictNextNumber)
1/1 [==============================] - 0s 253ms/step
[[[14.475913][14.757163][14.874351][14.702476][14.639976][14.624351][14.655601]]]
While the expected output should be an array of integers [24, 12, 3, 5, 11, 8, 4].
I'm having trouble figuring out what the problem is. Keras complained a lot about the shapes at first but when it was handled I kept receiving bad results. Any help would be appreciated.