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
0
votes
1 answer

How to set up inputs for Keras stateful LSTM layer?

I'm having trouble setting up the inputs for stateful=True LSTM layer in Keras. This is what I have so far: clear_session() model = Sequential() model.add(LSTM(hidden_units, batch_input_shape=(1,1,1), return_sequences=False,…
Keith
  • 47
  • 4
0
votes
0 answers

LSTM predicts differently as the length of input data changes

NOTE: all the numbers below are indicative only. I trained my LSTM model with the following parameters: batch_size = 32 time_step = 5 I know I need at least 5 samples to feed my model.predict() in order to predict the next outcome into the future.…
Joseph_Marzbani
  • 1,796
  • 4
  • 22
  • 36
0
votes
0 answers

Keras Stateful LSTM inference on Flask

I am running a service where I run inference on a stateful LSTM using Keras. However I am wondering what the threading semantics are here. I am not asking how to store models per flask session, I am more interested in what is happening under the…
user293895
  • 1,465
  • 3
  • 22
  • 39
0
votes
1 answer

nn.ModuleList not allowing to pass hidden and cell value

I have a class with LSTM and then nn.ModuleList where i have defined two more LSTM layers but the forward function for loop is failing with error "forward() takes 1 positional argument but 3 were given". Have shared the code and error below. Looks…
Amit
  • 11
  • 2
0
votes
1 answer

how to load a (multivariate) timeseries into a neural network /LSTM

How can I load a time series such as: into a neural network (LSTM). So far, I have seen approaches where this matrix is transposed…
Georg Heiler
  • 16,916
  • 36
  • 162
  • 292
0
votes
2 answers

For LSTM variables I get error "tensorflow:Gradients do not exist for variables"

Hi I have a bidirectional LSTM layer: class BiDirLSTMInput(Layer): def __init__(self): self.bidir_lstm = Bidirectional( LSTM(32, return_sequences=True,return_state=True) ) def call(self,…
LLB
  • 81
  • 1
  • 6
0
votes
2 answers

Build LSTM model for one inupt and two outputs

I want to build a LSTM model with one input and two outputs. My data is same as figure. My model is as below. But it only predict one output. could you help me to design the model for two outputs? thanks s1 = MinMaxScaler(feature_range=(-1,1)) Xs =…
Sadcow
  • 680
  • 5
  • 13
0
votes
1 answer

Stateful vs Stateless LSTM

I am trying to use LSTM in Keras and I am not sure whether I should used statefull or stateless LSTM. I have read many resources online but seem like they do not apply to my case. I have a long predictor series X=[X1,X2,....,Xn] and a long response…
TDo
  • 686
  • 4
  • 9
  • 22
0
votes
0 answers

Is there a way in Keras to not have the y size equal to X batch size for stateful LSTM?

I try to update the weight only at the end of batches and I know that this is the default behavior but I don't understand why you need to have your X and y the same size? If I have X.shape(12,32,64) in which I use the batch size 12, so just one…
Val Valli
  • 55
  • 5
0
votes
1 answer

Is there a way to pass along temporal weights to a loss function?

Background Currently, I'm using an LSTM to perform a regression. I'm using small batch sizes with a reasonably large amount of timesteps (but much, much fewer than the number of timesteps I have). I'm attempting to transition to larger batches with…
OmnipotentEntity
  • 16,531
  • 6
  • 62
  • 96
0
votes
1 answer

LSTM Autoencoder producing poor results in test data

I'm applying LSTM autoencoder for anomaly detection. Since anomaly data are very few as compared to normal data, only normal instances are used for the training. Testing data consists of both anomalies and normal instances. During the training, the…
ab.sharma
  • 180
  • 3
  • 12
0
votes
1 answer

Basic time series prediction with lstm

I have a sequence and I would like to do the simplest LSTM possible to predict the rest of the sequence. Meaning I want to start by using only the previous step to predict the next one and then add more steps. I want to use the predicted values as…
0
votes
0 answers

Keras: How to retrieve hidden states and/or cell states from several layers of LSTM?

Need some help to capture hidden states and/or cell states for the following LSTM model for each layer Excerpts from the python code that I could patch together: model = Sequential() model.add(LSTM(units=50, return_sequences=True,…
square_one
  • 101
  • 4
0
votes
1 answer

Providing inputs to LSTM cell in keras API

I am reading about LSTM in deep learning. From Prof. Andrew Ng course LSTM three inputs for each LSTM cell. Inputs are cell state from previous cell i.e., "c" superscript (t-1) and output of LSTM cell "a" super script (t-1) and input x super script…
venkysmarty
  • 11,099
  • 25
  • 101
  • 184
0
votes
0 answers

The two structures don't have the same nested structure while adding return_state=True over LSTM

I don't know if it is kind of bug or an error. I have also reported this issue here. The thing I am trying to do is that I want to make my custom LSTM statefull. So this code running fine without adding return_state=True. Once I add this to the code…
sariii
  • 2,020
  • 6
  • 29
  • 57