lstm

why set return_sequences=True and stateful=True for tf.keras.layers.LSTM?

为君一笑 提交于 2021-02-17 16:38:22
问题 I am learning tensorflow2.0 and follow the tutorial. In the rnn example, I found the code: def build_model(vocab_size, embedding_dim, rnn_units, batch_size): model = tf.keras.Sequential([ tf.keras.layers.Embedding(vocab_size, embedding_dim, batch_input_shape=[batch_size, None]), tf.keras.layers.LSTM(rnn_units, return_sequences=True, stateful=True, recurrent_initializer='glorot_uniform'), tf.keras.layers.Dense(vocab_size) ]) return model My question is: why the code set the argument return

why set return_sequences=True and stateful=True for tf.keras.layers.LSTM?

不问归期 提交于 2021-02-17 16:36:26
问题 I am learning tensorflow2.0 and follow the tutorial. In the rnn example, I found the code: def build_model(vocab_size, embedding_dim, rnn_units, batch_size): model = tf.keras.Sequential([ tf.keras.layers.Embedding(vocab_size, embedding_dim, batch_input_shape=[batch_size, None]), tf.keras.layers.LSTM(rnn_units, return_sequences=True, stateful=True, recurrent_initializer='glorot_uniform'), tf.keras.layers.Dense(vocab_size) ]) return model My question is: why the code set the argument return

LSTM produces identical forecast for each input

不羁的心 提交于 2021-02-11 13:25:36
问题 I've been working on reproducing a CNN-LSTM model for PV power forecasting from literature for the past four weeks for my Master Thesis in Energy Science (http://www.mdpi.com/2076-3417/8/8/1286). However I've been stuck on a seemingly simple issue: Any configuration of LSTM model that I've tried yields one of two things: Rediculous output, makes no sense whatsoever (flat line, complete stochasticity, negative values, you name it) Exactly the same (very believable) PV power forecast. I've done

LSTM to forecast numerical data by having categorical data as input

别来无恙 提交于 2021-02-11 12:50:53
问题 I have a similar DataFrame : df = pd.DataFrame([ {'date':'2021-01-15', 'value':145, 'label':'negative'}, {'date':'2021-01-16', 'value':144, 'label':'positive'}, {'date':'2021-01-17', 'value':147, 'label':'positive'}, {'date':'2021-01-18', 'value':146, 'label':'negative'}, {'date':'2021-01-19', 'value':155, 'label':'negative'}, {'date':'2021-01-20', 'value':157, 'label':'positive'}, {'date':'2021-01-21', 'value':158, 'label':'positive'}, {'date':'2021-01-22', 'value':157, 'label':'negative'},

keras LSTM model - a tf 1.15 equivalent that works with tflite

喜夏-厌秋 提交于 2021-02-11 12:44:49
问题 TLDR : How to implement this model using tf.lite.experimental.nn.TFLiteLSTMCell, tf.lite.experimental.nn.dynamic_rnn instead keras.layers.LSTM ? I have this network in keras: inputs = keras.Input(shape=(1, 52)) state_1_h = keras.Input(shape=(200,)) state_1_c = keras.Input(shape=(200,)) x1, state_1_h_out, state_1_c_out = layers.LSTM(200, return_sequences=True, input_shape=(sequence_length, 52), return_state=True)(inputs, initial_state=[state_1_h, state_1_c]) output = layers.Dense(13)(x1) model

Input Pipeline for LSTM with Timeseries Data Using a Large Dataset with Multiple .csv in Tensorflow

此生再无相见时 提交于 2021-02-11 11:59:32
问题 Currently I can train a LSTM network using one csv file based on this tutorial: https://machinelearningmastery.com/how-to-develop-lstm-models-for-time-series-forecasting/ This code generate sliding windows where the last n_steps of the features are saved to predict the actual target (similar to this: Keras LSTM - feed sequence data with Tensorflow dataset API from the generator): #%% Import import pandas as pd import tensorflow as tf from tensorflow.python.keras.models import Sequential,

Creating sequence vector from text in Python

风格不统一 提交于 2021-02-11 11:45:21
问题 I am now trying to prepare the input data for LSTM-based NN. I have some big number of text documents and what i want is to make sequence vectors for each document so i am able to feed them as train data to LSTM RNN. My poor approach: import re import numpy as np #raw data train_docs = ['this is text number one', 'another text that i have'] #put all docs together train_data = '' for val in train_docs: train_data += ' ' + val tokens = np.unique(re.findall('[a-zа-я0-9]+', train_data.lower()))

ValueError: Expected target size (128, 44), got torch.Size([128, 100]), LSTM Pytorch

醉酒当歌 提交于 2021-02-10 18:34:42
问题 I want to build a model, that predicts next character based on the previous characters. I have spliced text into sequences of integers with length = 100(using dataset and dataloader). Dimensions of my input and target variables are: inputs dimension: (batch_size,sequence length). In my case (128,100) targets dimension: (batch_size,sequence length). In my case (128,100) After forward pass I get dimension of my predictions: (batch_size, sequence_length, vocabulary_size) which is in my case (128

ValueError: Expected target size (128, 44), got torch.Size([128, 100]), LSTM Pytorch

可紊 提交于 2021-02-10 18:31:53
问题 I want to build a model, that predicts next character based on the previous characters. I have spliced text into sequences of integers with length = 100(using dataset and dataloader). Dimensions of my input and target variables are: inputs dimension: (batch_size,sequence length). In my case (128,100) targets dimension: (batch_size,sequence length). In my case (128,100) After forward pass I get dimension of my predictions: (batch_size, sequence_length, vocabulary_size) which is in my case (128

Does tensorflow allow LSTM deconvolution ( convlstm2d) as it does for 2D convolution?

你说的曾经没有我的故事 提交于 2021-02-10 15:11:55
问题 I am trying to augment a network. For the convolution part, I am using convlstm2d from keras. Is there a process to perform deconvolution ( i.e. lstmdeconv2d ? ) 回答1: There is Conv3D for that, checkout this example used to predict the next frame 回答2: It should be possible to combine any model with the TimeDistributed wrapper. So you can create a deconv-model, and apply it on the output (which is a sequence of vectors) of the LSTM using the TimeDistributed wrapper. An example. First create a