LSTM Keras API: Handling two cases; y<t> = x<t+1> and y<t> = x<t>

I’m learning how to implement LSTM using Keras API, and got a question regard how I can handle two different cases; y = x and y = x

For example, the following code builds a simple LSTM in Keras:

inputs = tf.random.normal([32, 10, 8])
lstm = tf.keras.layers.LSTM(4, return_sequences=True, return_state=True)
whole_seq_output, final_memory_state, final_carry_state = lstm(inputs)

When doing training for name entity task y equals to x, but when doing inferencing then y = x. But it seems like there is no argument/parameter specifying these cases when initializing LSTM in Keras.

Is it that these things are being handled internally all by Keras API by itself or is there something I’m missing?


1 Like