lstm

Building multiple models in the same graph

余生颓废 提交于 2019-12-11 18:36:32
问题 I am attempting to build two similar models predicting different output types. One predicts between two categories and the other has six output categories. Their inputs are the same and they are both LSTM RNN. I have separated training and predicting out into separate functions in each of their files, model1.py, model2.py. I have made the mistake of naming variables in each model the same thing so that when I call predict1 and predict2 from model1 and model2 respectively I get the following

How to visualize LSTM cell Tensorflow Matplotlib?

孤人 提交于 2019-12-11 18:32:37
问题 I have created LSTM based training model: def load_data_old(df_, seq_len): data_raw = df_.values data = [] for index in range(len(data_raw) - seq_len): data.append(data_raw[index: index + seq_len]) data = np.array(data); valid_set_size = int(np.round(valid_set_size_percentage/100*data.shape[0])); test_set_size = int(np.round(test_set_size_percentage/100*data.shape[0])); train_set_size = data.shape[0] - (valid_set_size + test_set_size); x_train = data[:train_set_size,:-1,:-1] y_train = data[

Why not to use mean square error for classification problem

半城伤御伤魂 提交于 2019-12-11 17:45:49
问题 I am trying to implement a simple binary classification problem using RNN LSTM and still not available to figure out the correct loss function for the network. The issue is, when I use the cross_binary_entophy as loss function, the loss value for training and testing is relatively high as compared to using a mean_square_error function. Upon research, I came across to justifications that binary cross entropy should be used for classification problem and MSE for the regression problem. However,

Tensorflow raw_rnn retrieve tensor of shape BATCH x DIM from embedding matrix

萝らか妹 提交于 2019-12-11 17:24:32
问题 I am implementing encoder-decoder lstm, where I have to do custom computation at each step of the encoder. So, I am using raw_rnn . However, I am facing a problem accessing an element from the embeddings which is shaped as Batch x Time steps x Embedding dimensionality at time step time . Here is my setup: import tensorflow as tf import numpy as np batch_size, max_time, input_embedding_size = 5, 10, 16 vocab_size, num_units = 50, 64 encoder_inputs = tf.placeholder(shape=(None, None), dtype=tf

Keras LSTM multidimensional output error — expected time_distributed_17 to have 3 dimensions, but got array with shape (1824, 3)

泪湿孤枕 提交于 2019-12-11 16:02:36
问题 I am trying to predict multidimensional values in sequence, e.g. [[0, 0, 2], [1, 0, 3], [2, 3, 4], [3, 2, 5], [4, 0, 6], [5, 0, 7] ... ] and want each of the [x, y, z] dimensions to be captured by the LSTM. When I attempt to run model.fit() on the model below, I get the error in the title, ValueError: Error when checking target: expected time_distributed_19 to have 3 dimensions, but got array with shape (1824, 3) I know the output layer should have three dimensions, but I'm getting confused

Keras: Understanding the number of trainable LSTM parameters

蓝咒 提交于 2019-12-11 15:43:00
问题 I have run a Keras LSTM demo containing the following code (after line 166): m = 1 model=Sequential() dim_in = m dim_out = m nb_units = 10 model.add(LSTM(input_shape=(None, dim_in), return_sequences=True, units=nb_units)) model.add(TimeDistributed(Dense(activation='linear', units=dim_out))) model.compile(loss = 'mse', optimizer = 'rmsprop') When I prepend a call to model.summary() , I see the following output: _________________________________________________________________ Layer (type)

architecture for multivariate time series networks where some variables are shared across units

穿精又带淫゛_ 提交于 2019-12-11 15:27:13
问题 I've got a time series that has the following shape: arr.shape Out[9]: (2864, 98, 34) So, 2864 units, 98 time steps, and 34 variables. The 98 time steps are annual. I've also got a "global" variable that is also monthly. It's global in the sense that it applies to each of the N units. pdat.shape Out[10]: (1176, 1) 1176/12 Out[11]: 98.0 I'm trying to build a model that will jointly predict the 34 input variables (really my interest centers on a few of them), as well as the monthly global

How to predict the class by training only partial sequence as Input using LSTM's in Keras?

↘锁芯ラ 提交于 2019-12-11 14:50:02
问题 Objective I would like to predict the class if I give only partial input into the model . (Working with sequence data. Using Keras LSTM's) What I have done I have implemented my model based on the answers what I got from here answered by @Kbrose In such a way, i should train my training data with variable length sequence which corresponds to particular class. Here, I would like to clarify some queries related to fit.generator, batch sizes, validation_steps and my Model results Data X_train

is this correctly work on predict next value in keras?

断了今生、忘了曾经 提交于 2019-12-11 14:23:23
问题 here is my code ... look_back = 20 train_size = int(len(data) * 0.80) test_size = len(data) - train_size train = data[0:train_size] test = data[train_size:len(data)] x_train, y_train = create_dataset(train, look_back) x_test, y_test = create_dataset(test, look_back) x_train = np.reshape(x_train, (x_train.shape[0], x_train.shape[1], 1)) x_test = np.reshape(x_test, (x_test.shape[0], x_test.shape[1], 1)) y_train=np.repeat(y_train.reshape(-1,1), 20, axis=1).reshape(-1,20,1) y_test=np.repeat(y

On training LSTMs efficiently but well, parallelism vs training regime

半世苍凉 提交于 2019-12-11 14:18:49
问题 For a model that I intend to spontaneously generate sequences I find that training it sample by sample and keeping state in between feels most natural. I've managed to construct this in Keras after reading many helpful resources. (SO: Q and two fantastic answers, Macine Learning Mastery 1, 2, 3) First a sequence is constructed (in my case one-hot encoded too). X and Y are procuded from this sequence by shifting Y forward one time step. Training is done in batches of one sample and one time