# Modifying LSTM to include forecast

I am looking at LSTM example here

However, I am not sure how to modify the setup if I have forecast available (assuming perfect forecast) for TEMP: Temperature and PRES: Pressure at time t.

i.e. pollution_t = fn(TEMP_t, PRES_t, TEMP_t_1, PRES_t_1, ..., othervariables and lagged values)

_t represents the perfect forecast available

_t_1 represents the variable values at previous time steps

Basically I am looking for something of the following setup:

You need a bidirectional LSTM. The temporal direction on the original LSTM and on GRU type cell connectivity is forward in time. Fortunately, the bidirectional class is available in Keras.

from keras.models import Sequential
from keras.layers import LSTM
from keras.layers import TimeDistributed
from keras.layers import Bidirectional
...
model = Sequential()

When the loss function (for its derivative) is provided, it must return the error at $$t = t(i)$$, where $$i$$ is the index of the last sample in the sequence before the values become forecasts. This is the main distinction when the sequence includes both history and forecast.