Statefull or stateless architecture?

I’m on working on classification problem

My model architecture looks:

model = Sequential()
model.add(Masking(mask_value=0.0, input_shape=(30, 2)))
model.add(LSTM(100, return_sequences=True))
model.add(LSTM(50, return_sequences=True))
model.add(LSTM(50, return_sequences=False)) 
model.add(Dense(10, activation='relu'))
model.add(Dense(3, activation='softmax'))

The input is represented like this:

  • 2 features- up to 30 samples (time series with different series length, between 10-30 samples).
  • 3 different classes
  • Each series (each input) may be taken from different times.

I have read several articles and posts about stateless and stateful LSTMs.

If I understand correctly, then for the problem I’m describing above - the correct architecture is stateless LSTM
(because these are sample lengths from different times (and also different lengths).

Am I right ?

Hi @SAL, Apologies for the delayed response.
You are absolutely right. Since your sequences are independent, a stateless LSTM is the correct choice
A stateful LSTMs pass the final hidden states of one batch to the next, treating the entire dataset as one continuous sequence. It is only suitable, when two sequences in two batches have connections. Thanks!