lstm

using output from one LSTM as input into another lstm in tensorflow

时间秒杀一切 提交于 2020-05-28 07:25:04
问题 I want to build an LSTM based neural network which takes two kinds of inputs and predicts two kinds of outputs. A rough structure can be seen in following figure.. The output 2 is dependent upon output 1 and as described in answer to a similar question here, I have tried to implement this by setting the initial state of LSTM 2 from hidden states of LSTM 1. I have implemented this using tensorflow using following code. import tensorflow as tf from tensorflow.keras.layers import Input from

using output from one LSTM as input into another lstm in tensorflow

瘦欲@ 提交于 2020-05-28 07:25:00
问题 I want to build an LSTM based neural network which takes two kinds of inputs and predicts two kinds of outputs. A rough structure can be seen in following figure.. The output 2 is dependent upon output 1 and as described in answer to a similar question here, I have tried to implement this by setting the initial state of LSTM 2 from hidden states of LSTM 1. I have implemented this using tensorflow using following code. import tensorflow as tf from tensorflow.keras.layers import Input from

Default Initialization for Tensorflow LSTM states and weights?

痴心易碎 提交于 2020-05-26 09:54:27
问题 I am using the LSTM cell in Tensorflow. lstm_cell = tf.contrib.rnn.BasicLSTMCell(lstm_units) I was wondering how the weights and states are initialized or rather what the default initializer is for LSTM cells (states and weights) in Tensorflow? And is there an easy way to manually set an Initializer? Note: For tf.get_variable() the glorot_uniform_initializer is used as far as I could find out from the documentation. 回答1: First of all, there is a difference between the weights of a LSTM (the

Multivariate input LSTM in pytorch

旧城冷巷雨未停 提交于 2020-05-25 05:35:05
问题 I would like to implement LSTM for multivariate input in Pytorch . Following this article https://machinelearningmastery.com/how-to-develop-lstm-models-for-time-series-forecasting/ which uses keras, the input data are in shape of (number of samples, number of timesteps, number of parallel features) in_seq1 = array([10, 20, 30, 40, 50, 60, 70, 80, 90]) in_seq2 = array([15, 25, 35, 45, 55, 65, 75, 85, 95]) out_seq = array([in_seq1[i]+in_seq2[i] for i in range(len(in_seq1))]) . . . Input Output

Understanding a simple LSTM pytorch

南楼画角 提交于 2020-05-24 08:10:50
问题 import torch,ipdb import torch.autograd as autograd import torch.nn as nn import torch.nn.functional as F import torch.optim as optim from torch.autograd import Variable rnn = nn.LSTM(input_size=10, hidden_size=20, num_layers=2) input = Variable(torch.randn(5, 3, 10)) h0 = Variable(torch.randn(2, 3, 20)) c0 = Variable(torch.randn(2, 3, 20)) output, hn = rnn(input, (h0, c0)) This is the LSTM example from the docs. I don't know understand the following things: What is output-size and why is it

How to get reproducible result when running Keras with Tensorflow backend

一曲冷凌霜 提交于 2020-05-23 02:55:19
问题 Every time I run LSTM network with Keras in jupyter notebook, I got a different result, and I have googled a lot, and I have tried some different solutions, but none of they are work, here are some solutions I tried: set numpy random seed random_seed=2017 from numpy.random import seed seed(random_seed) set tensorflow random seed from tensorflow import set_random_seed set_random_seed(random_seed) set build-in random seed import random random.seed(random_seed) set PYTHONHASHSEED import os os

Predictions from a model become very small. The loss is either 0 or a positive constant

一曲冷凌霜 提交于 2020-05-17 06:06:39
问题 I am implementing the following architecture in Tensorflow. Dual Encoder LSTM https://i.stack.imgur.com/ZmcsX.png During the first few iterations, the loss remains 0.6915 but after that as you can see in the output below, no matter how many iterations I run, the loss keeps varying between -0.0 and a positive constant depending upon the hyperparams. This is happening because the predictions of my model become very small(close to zero) or very high (close to 1). So the model cannot be trained.

Predictions from a model become very small. The loss is either 0 or a positive constant

对着背影说爱祢 提交于 2020-05-17 06:04:52
问题 I am implementing the following architecture in Tensorflow. Dual Encoder LSTM https://i.stack.imgur.com/ZmcsX.png During the first few iterations, the loss remains 0.6915 but after that as you can see in the output below, no matter how many iterations I run, the loss keeps varying between -0.0 and a positive constant depending upon the hyperparams. This is happening because the predictions of my model become very small(close to zero) or very high (close to 1). So the model cannot be trained.

Merge or append multiple Keras TimeseriesGenerator objects into one

末鹿安然 提交于 2020-05-16 02:58:41
问题 I'm trying to make a LSTM model. The data is coming from a csv file that contains values for multiple stocks. I can't use all the rows as they appear in the file to make sequences because each sequence is only relevant in the context of its own stock, so I need to select the rows for each stock and make the sequences based on that. I have something like this: for stock in stocks: stock_df = df.loc[(df['symbol'] == stock)].copy() target = stock_df.pop('price') x = np.array(stock_df.values) y =

What is the default activation function of cudnnlstm in tensorflow

我的未来我决定 提交于 2020-05-14 07:42:06
问题 What's the default activation function of cudnnlstm in TensorFlow? How can I set an activation function such as relu ? Maybe it's just linear model? I read the document, but I did not find it. For example, the code is below: lstmcell=tf.contrib.cudnn_rnn.CudnnLSTM(1,encoder_size,direction="bidirectional") hq,_ =lstmcell(query) And I read the document of TensorFlow From this link. The function is below __init__( num_layers, num_units, input_mode=CUDNN_INPUT_LINEAR_MODE, direction=CUDNN_RNN