Questions tagged [lstm-stateful]

Tag refers to stateful long short-term memory (LSTM) cells in a neural network (i.e. cells that remember their state for the next training batch)

Stateful LSTMs will use the last state for each sample at index i in a training batch as initial state for the sample of index i in the following batch.

63 questions
31
votes
2 answers

Pytorch LSTM vs LSTMCell

What is the difference between LSTM and LSTMCell in Pytorch (currently version 1.1)? It seems that LSTMCell is a special case of LSTM (i.e. with only one layer, unidirectional, no dropout). Then, what's the purpose of having both implementations?…
dkv
  • 6,602
  • 10
  • 34
  • 54
4
votes
0 answers

Keras Lstm predicting next item, taking whole sequences or sliding window. Will sliding window need stateful LSTM?

I have a sequence prediction problem in which, given the last n items in a sequence I need to predict next item. I have more than 2 million sequences each with different timesteps (length of sequence), like some are just 5 and some are…
A.B
  • 20,110
  • 3
  • 37
  • 71
4
votes
1 answer

How to implement multi state LSTM RNN in keras

I have 1000 distinct users and the dataset consists activities of these users over the past 1 year. Total records are over 300K. The inputs for the LSTM RNN has the feature vectors corresponding to these users. The user is also included because…
ab.sharma
  • 180
  • 3
  • 12
4
votes
2 answers

Keras: Share a layer of weights across Training Examples (Not between layers)

The problem is the following. I have a categorical prediction task of vocabulary size 25K. On one of them (input vocab 10K, output dim i.e. embedding 50), I want to introduce a trainable weight matrix for a matrix multiplication between the input…
pythOnometrist
  • 6,531
  • 6
  • 30
  • 50
3
votes
1 answer

Stateful LSTM Tensorflow Invalid Input_h Shape Error

I am experimenting with stateful LSTM on a time-series regression problem by using TensorFlow. I apologize that I cannot share the dataset. Below is my code. train_feature = train_feature.reshape((train_feature.shape[0], 1,…
glorian
  • 53
  • 5
3
votes
0 answers

How to fix "Cannot update variable with shape [] using a Tensor with shape [1000], shapes must be equal." error in keras LSTM network?

I am trying to develop a stateful LSTM network. I am going to use algorithmic hyperparameter search, but before that, it should work with default parameters, however, it doesn't. I keep getting…
2
votes
1 answer

Keras stateful LSTM error: Specified a list with shape [4,1] from a tensor with shape [32,1]

With this code I get an error while I try to run the prediction with X_test. The error occurs after the fitting, while y_pred = model.predict(X_test) is executed. X_train.input_shape() -> (784, 300, 7) y_train.input_shape() -> (784, 300,…
bolli
  • 115
  • 5
2
votes
0 answers

Predicting out-of-sample time points with LSTM

I'm working on a time series forecasting problem using LSTM. The data is univariate and non-stationary. I followed the following tutorial: https://machinelearningmastery.com/time-series-forecasting-long-short-term-memory-network-python/ The data is…
Jasey Mon
  • 21
  • 1
2
votes
0 answers

How to convert this keras model (tf version 1.15, dynamic LSTM) to TFLite?

I need to build an LSTM network in Keras that is compatible with tensorflow 1.15. This is another post I opened, on how to create the network. keras LSTM model - a tf 1.15 equivalent that works with tflite The versions I am using: tf version:…
jonb
  • 845
  • 1
  • 13
  • 36
2
votes
1 answer

What is the relationship between batch size, timestep and error in LSTM (Keras)?

Let, Sample Size = 100 (X1,X2,...,X100) Timesteps = 5 Input Feature = 10 Error Calculation: How is the error calculation done when batch size = Sample size? My understanding: I will insert X1,X2,X3,X4,X5 into LSTM and get an output after 5…
2
votes
1 answer

Input 0 of layer lstm_35 is incompatible with the layer: expected ndim=3, found ndim=4. Full shape received: [None, 1966, 7059, 256]

I am creating a seq2seq model on word level embeddings for text summarisation and I am facing data shapes issue please help. thanks. encoder_input=Input(shape=(max_encoder_seq_length,)) …
2
votes
1 answer

Detecting changes in speed (given current xy position) with RNNs/LSTMs

How would I approach learning changes in speed using RNNs/LSTMs given x,y coordinates of continuous data? (I have to use a recurrent layer as this is a sub-problem of a bigger end-to-end model that does other things too) Training data…
2
votes
1 answer

How to pass categorical information along with numerical features in LSTM RNN

I have a dataset that contains activity data of 1000 users. Since the activity of one user differs from another user, I want the user attribute also send to the LSTM RNN model so that the model can learn better about each user's behavior. The…
2
votes
2 answers

Dense expects 2d but has got 3d in LSTM

In my model Xtrain shape : (62, 30, 100) Ytrain shape : (62, 1, 100) Xtest shape : (16, 30, 100) Ytest shape : (16, 1, 100) When I build my model, model = Sequential() model.add(LSTM(units=100, return_sequences= True,…
2
votes
1 answer

Why my accuracy is always 0.2 in this simple code

I am new in this field and trying to re-run an example LSTM code copied from internet. The accuracy of the LSTM model is always 0.2 but the predicted output is totally correct which means the accuracy should be 1. Could anyone tell me why? from…
1
2 3 4 5