<p>I was looking for an answer to the same question, and I came across <a href="https://arxiv.org/pdf/2003.05672.pdf" rel="nofollow noreferrer">the following paper from 2019</a> and the <a href="https://github.com/nla-group/ABBA-LSTM" rel="nofollow noreferrer">corresponding Git repo</a>. In particular, see section 5.3 in the paper. It seems like ABBA-LSTM is the solution, though it depends on the time series problem you're trying to solve.</p>
How to use LSTM to predict values from a different range than it was trained on
<p>I try to train a simple LSTM to predict the next number in a sequence (1,2,3,4,5 --> 6). </p>



<pre class="lang-python prettyprint-override"><code>from keras.models import Sequential
from keras.layers import LSTM, Dense
from sklearn.model_selection import train_test_split
import numpy as np
import matplotlib.pyplot as plt

xs = [[[(j+i)/100] for j in range(5)] for i in range(100)]
ys = [(i+5)/100 for i in range(100)]

x_train, x_test, y_train, y_test = train_test_split(xs, ys)

model = Sequential()
model.add(LSTM(1, input_shape=(5,1), return_sequences=True))
model.add(LSTM(1, return_sequences=False))
model.add(Dense(1))

model.compile(loss='mae', optimizer='adam', metrics=['accuracy'])

training = model.fit(x_train, y_train, epochs=200)

new_xs = np.array(xs)*5
new_ys = np.array(ys)*5
pred = model.predict(new_xs)
plt.scatter(range(len(pred)), pred, c='r')
plt.scatter(range(len(new_ys)), new_ys, c='b')
</code></pre>

<p>In order for the net to learn anything I had to normalize the training data (divided it by 100). It did work indeed for the data from the range it was trained on.</p>

<p>I want it to be able to predict the numbers form outside the range it was trained on, but as soon as it leaves the range, it starts to diverge:</p>

<p><a href="https://i.stack.imgur.com/dfNsq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dfNsq.png" alt="enter image description here"></a></p>

<p>When I increased the number of units in both LSTM layers to 30 it looks a little better, but it's still diverging:</p>

<p><a href="https://i.stack.imgur.com/Il3g7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Il3g7.png" alt="enter image description here"></a></p>

<p>Is LSTM capable of learning that task without adding an infinite number of units?</p>