import numpy as np
from keras.models import Sequential
from keras.layers import LSTM
from keras import optimizers
model = Sequential()
model.add(LSTM(1, input_shape=(2,3), return_sequences=True))
# data_input has a size of (2,3,2,3), i.e. samples = 2, time length = 3, shape of individual input = (2,3)
data_input = np.array([[[[1,1,1], [2,2,2]], [[1,1,1],[2,2,2]], [[1,1,1],[2,2,2]]],[[[1,1,1], [2,2,2]], [[1,1,1],[2,2,2]], [[1,1,1],[2,2,2]]]])
# data_output has a size of (2,1,2,1), i.e. samples = 2, only shows the final output, and the shape of individual output= (2,1)
data_output = np.array([[[[1],[2]],[[1],[2]],[[1],[2]]],[[[1],[2]],[[1],[2]],[[1],[2]]]])
model.compile(optimizer = 'Adam',loss='mean_squared_error')
model.fit(data_input,data_output)