# Questions tagged [lstm]

Long Short Term Memory. A neural network architecture that contains recurrent NN blocks that can remember a value for an arbitrary length of time. A very popular building block for deep NN.

3,127 questions

**0**

votes

**0**answers

7 views

### How to predict value in every 120 minutes using LSTM in python

I want to predict value in every 120 minutes continuous using LSTM model. Here I wrote the code for predction. But I'm not getting proper prediction values . Here from start time I need to predict ...

**0**

votes

**0**answers

14 views

### TypeError: Tensor objects are only iterable when eager execution is enabled. To iterate over this tensor use tf.map_fn

So I run into this error, I am trying to have a custom layer in seq2seq model.
the main function that runs into error is rev_entropy and in the first for loop when it wants to iterate over the tensor.
...

**2**

votes

**1**answer

30 views

### Predict a future result of column based on other columns using LSTM

I want to predict a future result of the column based on other columns using LSTM.
My Data Frame is time indexed and I have multiple columns including the Emergency column that I want to predict(...

**0**

votes

**0**answers

21 views

### how can I calculate entropy on array with shape (?,20) along rows

So I need to calculate entropy function on each row of my array with shape(?,20).
Also, this calculation is going to be on one layer of Seq2Seq model.
when I pass the array to this function, the ...

**0**

votes

**0**answers

18 views

### How to divide label data into time series in Keras?

I'm trying to build a simple lstm model with timesteps and using a small dataset which contains 36 rows and a total of 3 features - year, month, price.
I used pandas and numpy to reshape year and ...

**0**

votes

**0**answers

11 views

### implement keras ConvLSTM2D with seq frames to forcast one single value

I try to implement an ConvLSTM2D to use a sequence of low resolution video frames to make a prediction of what will append after. The prediction is not a Frame or a video it is a single values (kind ...

**0**

votes

**0**answers

15 views

### How exactly the keras layer works?

I try to create a sentiment analysis that have 7 classification.
Let's say, I have 100.000 unique word (already converted into 100.000 integer) which have the longest input is 41.
I created 3 layer ...

**0**

votes

**1**answer

25 views

### How to add Conv2D layers with LSTM in Keras?

I'm trying to identify the sequence of images. I've 2 images and I need to identify the 3rd one. All are color images.
I'm getting below error:
ValueError: Error when checking input: expected
...

**-1**

votes

**0**answers

26 views

### How to use Keras model to forecast the future value?

My model:
model = Sequential()
model.add(LSTM(512, input_shape=(None, 1), return_sequences=True))
model.add(Dropout(0.3))
model.add(LSTM(512, input_shape=(None, 1)))
model.add(Dropout(0.3))
model....

**-1**

votes

**0**answers

19 views

### How to use the output of a lstm model as input of another model

I have two models, one is a keras LSTM model and the other one is a scikit-learn gradient boosting classifier. And I want to use the output of the LSTM model as one of the input variables for the ...

**1**

vote

**0**answers

13 views

### Value error while predicting result using Convlstm2d with attention layer?

I am integrating Attention mechanism with convlstm2d. I can build and fit the model but getting value error while predicting the result.
I am using attention layer implementation of from:
https://www....

**0**

votes

**0**answers

17 views

### How can I fix the 'instance of class Layer' error by creating LSTM with multiple inputs?

I'm creating a LSTM model with multiple categorical inputs. I've 169.856 samples, max 105 timesteps per sample (so I used paddings), and 2 categorical features. I've one label per sequence. Because ...

**0**

votes

**1**answer

26 views

### How to write an RNN/LSTM custom layer in swift for tensorflow?

I have a simple tensorflow model with lstm layers. I want to convert the model to .mlmodel format. However, I think, as of now, CoreML does not support LSTM layers and hence I need to write a custom ...

**3**

votes

**1**answer

26 views

### How to understand this on pytorch website?

I notice this on pytorch official website: https://pytorch.org/docs/stable/nn.html
If the following conditions are satisfied:
1) cudnn is enabled,
2) input data is on the GPU,
3) input data has ...

**2**

votes

**0**answers

33 views

### How to shape 2-feature input data for LSTM

I am using a RNN with LSTM nodes in Keras for a time series prediction. I have two input features and one output feature and I'm using a sliding window of size 4 and stepsize 1.
So I'm trying to ...

**1**

vote

**0**answers

26 views

### LSTM network expects target at last layer to have 2 dimensions, but got array with shape (996, 1, 1)

I am trying to train an LSTM with keras using TensorFlow backend on toy data and am getting this error:
ValueError: Error when checking target: expected dense_39 to have 2 dimensions, but got array ...

**-1**

votes

**1**answer

12 views

### When trying to feed in variable sequences to keras LSTMs ValueError: Error when checking input?

My model:
model = Sequential()
model.add( LSTM(25, batch_input_shape = (None, None, 19), return_sequences = True ) )
model.add(Dense(4, activation ='tanh'))
model.compile(loss='mean_squared_error'...

**1**

vote

**2**answers

26 views

### Keras LSTM problem, how set up correctly a neural network for time series?

i'm trying to undestand how lstm works for predict time series with Keras.
Here's my example.
I use an accelerometer and i have a 128.000 time series. I thought to take:
n_steps_in = 10.000
...

**0**

votes

**1**answer

30 views

### In Keras, how to get 3D input and 3D output for LSTM layers

In my original setting, I got
X1 = (1200,40,1)
y1 = (1200,10)
Then, I work perfectly with my codes:
model = Sequential()
model.add(LSTM(12, input_shape=(40, 1), return_sequences=True))
model.add(...

**0**

votes

**0**answers

6 views

### bptt - how do I average the present with the future?

In bptt, in each time step(besides of the last time step, which is the first to handle) we have two things we want the memory to be in the last time step:
First, we have the output that the net should ...

**0**

votes

**0**answers

22 views

### Load and Use Keras model built using LSTM network in C++

I have created LSTM network using Keras for next word prediction based on the context of the previous words in a sentence. I have written the code in Python, but have to deploy it with existing code ...

**1**

vote

**0**answers

27 views

### Input(shape=(None,)) is giving following error - ValueError: setting an array element with a sequence

I am trying to create a model which will take dynamic input, and I wrote following code for the same.
inpt = Input(shape=(None,))
emb_layer = Embedding(vocabulary_size, 100, weights=[embedding_matrix]...

**0**

votes

**0**answers

37 views

### Validation loss >> train loss, same data, binary classifier

I implemented this paper's neural net, with some differences (img below), for EEG classification; train_on_batch performance is excellent, with very low loss - but test_on_batch performance, though on ...

**0**

votes

**0**answers

17 views

### Can I concatenate a timeserie for price prediction based on passed input prices with another different input timeserie of passed volume?

I'm working to expand a working program that in python is downloading 5 years of daily stock data to train the next Open day price prediction using the past 60 opening days prices.
The original ...

**0**

votes

**0**answers

10 views

### LSTM using Timedistributed is same as not using

I followed some LSTM tutorial from the internet.
When I tried the "Many-to-Many" LSTM, I used Timedistributed with Dense layer.
But, I found that the summary of the LSTM model with Timedistributed ...

**0**

votes

**1**answer

21 views

### How to fix Keras LSTM input / output dimensions?

My model is:
model = Sequential()
model.add(Embedding(input_dim=vocab_size,
output_dim=1024, input_length=self.SEQ_LENGTH))
model.add(LSTM(vocab_size))
model.add(Dropout(rate=0....

**2**

votes

**0**answers

26 views

### ValueError: Error when checking target: expected lstm_27 to have 2 dimensions, but got array with shape (1, 11, 1)

I am trying to incorporate a simple LSTM autoencoder mentioned in the keras.io website with a sequence input. It is throwing an error at the LSTM layer input.
from keras.layers import Input, LSTM, ...

**-1**

votes

**0**answers

9 views

### Restore and Evaluate Pre-Trained LSTM Model: Tensor is not an element of this graph

I tried to restore a pre-trained LSTM model and use it to evaluate new data. But it kept saying a Tensor is not an element of this graph. I tried many solutions but none give a result.
def main():
...

**0**

votes

**0**answers

15 views

### How to save attention network model in h5 format file

I'm using attention network for document classification. The training part completed successfully. But I'm not able to save model in h5 format file.
My backend is Theano and I'm using following python ...

**0**

votes

**0**answers

17 views

### How can achieve LSTM/RNN history-based prediction by using Keras backend?

For my experiment, I have a formatted csv file with 1440 columns like following:
timestamps[row_index] | feature1 | feature2 | ... | feature1439 | feature1440 |
--------------------------------------...

**1**

vote

**1**answer

15 views

### How does this sequential model work without a time distributed?

I followed a tutorial to make a Keras LSTM model that has 80 timesteps, looks at 80 words per timestep, and predicts 1 word at a time. Now that I'm making a different LSTM model with the functional ...

**0**

votes

**1**answer

15 views

### How to get a 2D shape ready for a Bi-LSTM in Keras

I've got a 2D numpy matrix (from a DataFrame) of already condensed word vectors (I used a max pooling technique, am trying to compare a logres to a bi-LSTM approach), and I'm not sure how to prepare ...

**0**

votes

**0**answers

12 views

### keras lstm bad prediction

I have dataset with metrics record and failure list with metrics failure
I want to predict with lstm time before failure and metrics failure
i try to use lstm with keras in python 3.5
# metric ...

**-2**

votes

**0**answers

17 views

### LSTM Input Timestep after Timestep

Is there a way in Keras to manually input 6 variable in the LSTM, and input the next 6 and so on, instead of input timestep*inputsize at once?
I need that because I don´t have the whole input set at ...

**0**

votes

**0**answers

24 views

### How do I implement a stacked LSTM autoencoder which inputs word/character embeddings?

I'm trying to implement a stacked LSTM autoencoder which inputs character embeddings and word embeddings as separate inputs, to return the same as 2 separate outputs.
For now, I am passing the word ...

**0**

votes

**1**answer

56 views

### Accuracy of LSTM model is very low

I am trying to build a model to predict text.
The x_train is of shape : (19992, 40, 1)
array([[[0.00680272],
[0.01417234],
[0. ],
...,
[0.01473923],
[...

**0**

votes

**0**answers

12 views

### User Sequences as input to LSTM

Does LSTM trains on user sequences automatically if userid is given as input feature or we need to create separate sequences?
Conceptually, every user sequence is different intention is to train LSTM ...

**2**

votes

**1**answer

93 views

+50

### Why does my keras LSTM model get stuck in an infinite loop?

I am trying to build a small LSTM that can learn to write code (even if it's garbage code) by training it on existing Python code. I have concatenated a few thousand lines of code together in one file ...

**0**

votes

**0**answers

24 views

### Implementing class weights in a tf.keras LSTM

A similar question was asked previously without a sufficient answer: Keras: LSTM with class weights
I am trying to implement class weights in a tf.keras LSTM. In order to use class_weights, the model'...

**2**

votes

**2**answers

22 views

### Whats the output for Keras categorical_accuracy metrics?

I cant find proper description of metrics outputs.
For example if I use
model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['accuracy'])
then I get loss and accuracy tr_loss, ...

**-1**

votes

**0**answers

13 views

### RNN encoder-decoder model keeps overfitting

i've trainning a machine translation model (from english to vietnamese) with RNN, LSTM with 25000 example pairs (for training set -> 20000, test set -> 5000) the model i used like below but val_acc ...

**1**

vote

**1**answer

31 views

### How to calculate correct batch size for LSTM?

I have a daily time series data like below.
CashIn CashOut
Date
2016-01-01 0.0 6500.0
2016-01-02 0.0 23110.0
2016-01-03 0.0 7070.0
2016-01-04 0.0 18520.0
...

**-1**

votes

**0**answers

8 views

### Predicting song genre using LSTM

I have a dataset of songs based on genres. For example, a song may hold {5, 2, 3} as scores set for Sentimental, Rock and Jazz. In total there are 800 songs sequentially arranged. I want to predict ...

**0**

votes

**3**answers

82 views

### Error when running LSTM model, Loss: NaN values

My LSTM model using Keras and Tensorflow is giving loss: nan values.
I have tried to reduce the learning rate but still get nan and decreasing overall accuracy, and have also used np.any(np.isnan(...

**0**

votes

**1**answer

13 views

### Predicting with different time step with a model trained for different time step data

I have trained my LSTM with 3 time steps. Following is the Keras LSTM layer.
model.add(LSTM(32, return_sequences=True, input_shape=(None, 3))).
ex:
X Y
[[1,2,3],[2,...

**3**

votes

**1**answer

69 views

### Initializing LSTM States Before the Prediction of a Day

I would like to use an LSTM to predict a daily time series that is strongly dependent on the season. As test data, days from different seasons are used. Before the prediction for the test data takes ...

**0**

votes

**0**answers

9 views

### Error when checking target: expected time_distributed_56 to have 3 dimensions, but got array with shape (1000, 1)

I am working with Keras, trying to add an Embedding layer before the LSTM layers. Therefore, my input data is no longer a one-hot representation and contains only the indices of the instances. Here is ...

**0**

votes

**1**answer

25 views

### Keras Sequential data processing order

My goals is to develop a Sequence-to-Sequence model. Assume the input data to a Keras Sequential LSTM model is time-ordered and shaped as
(samples, time_length, num_features)
For now, samples = 1 ...

**1**

vote

**1**answer

17 views

### How to use multiple layers in ConvLSTM model

I like to check my model using multiple layers of ConvLSTM model. Shape of my training data is
trainX.shape (5000, 200, 4) # testX.shape (2627, 200, 4)
Following is my code that works fine
print('...

**0**

votes

**0**answers

10 views

### How to find the inverse of a nonlinear function with lstm

I have a system based on a combination of two other functions y=f(g(x(t)).
f(x) is nonlinear and unknown with no clear closed form.However i can learn and characterize it with an lstm.
I want to ...