recurrent-neural-network

TypeError when trying to create a BLSTM network in Keras

早过忘川 提交于 2019-12-10 16:44:49
问题 I'm a bit new to Keras and deep learning. I'm currently trying to replicate this paper but when I'm compiling the second model (with the LSTMs) I get the following error: "TypeError: unsupported operand type(s) for +: 'NoneType' and 'int'" The description of the model is this: Input (length T is appliance specific window size) Parallel 1D convolution with filter size 3, 5, and 7 respectively, stride=1 , number of filters=32 , activation type=linear , border mode=same Merge layer which

Training a multi-variate multi-series regression problem with stateful LSTMs in Keras

为君一笑 提交于 2019-12-10 15:43:34
问题 I have time series of P processes, each of varying length but all having 5 variables (dimensions). I am trying to predict the estimated lifetime of a test process. I am approaching this problem with a stateful LSTM in Keras. But I am not sure if my training process is correct. I divide each sequence into batches of length 30 . So each sequence is of the shape (s_i, 30, 5) , where s_i is different for each of the P sequences ( s_i = len(P_i)//30 ). I append all sequences into my training data

Explanation of GRU cell in Tensorflow?

怎甘沉沦 提交于 2019-12-10 14:35:58
问题 Following code of Tensorflow's GRUCell unit shows typical operations to get a updated hidden state, when previous hidden state is provided along with current input in the sequence. def __call__(self, inputs, state, scope=None): """Gated recurrent unit (GRU) with nunits cells.""" with vs.variable_scope(scope or type(self).__name__): # "GRUCell" with vs.variable_scope("Gates"): # Reset gate and update gate. # We start with bias of 1.0 to not reset and not update. r, u = array_ops.split(1, 2,

How to code a sequence to sequence RNN in keras?

爱⌒轻易说出口 提交于 2019-12-10 13:24:52
问题 I am trying to write a sequence to sequence RNN in keras. I coded this program using what I understood from the web. I first tokenized the text then converted the text into sequence and padded to form feature variable X . The target variable Y was obtained first shifting x to left and then padding it. Lastly I fed my feature and target variable to my LSTM model. This is my code I written in keras for that purpose. from keras.preprocessing.text import Tokenizer,base_filter from keras

RNN time series predictions with multiple time series dimension with Keras, Tensorflow

一曲冷凌霜 提交于 2019-12-10 11:25:41
问题 I am trying to run a RNN/LSTM network on some time series sets. It should be mentioned that the time series are being classified. I have ~600 different time series, and each of these has 930 timesteps with features in them. I have structured my data into a numpy 3D array that is structured like: X = [666 observations/series, 930 timesteps in each observation, 15 features] Y = [666 observations/series, 930 timesteps in each observation, 2 features] For training and validation data I split the

Tensorflow RNN input size

夙愿已清 提交于 2019-12-10 10:57:24
问题 I am trying to use tensorflow to create a recurrent neural network. My code is something like this: import tensorflow as tf rnn_cell = tf.nn.rnn_cell.GRUCell(3) inputs = [tf.constant([[0, 1]], dtype=tf.float32), tf.constant([[2, 3]], dtype=tf.float32)] outputs, end = tf.nn.rnn(rnn_cell, inputs, dtype=tf.float32) Now, everything runs just fine. However, I am rather confused by what is actually going on. The output dimensions are always the batch size x the size of the rnn cell's hidden state -

Keras LSTM - feed sequence data with Tensorflow dataset API from the generator

♀尐吖头ヾ 提交于 2019-12-09 23:47:51
问题 I am trying to solve how I can feed data to my LSTM model for training. (I will simplify the problem in my example below.) I have the following data format in csv files in my dataset. Timestep Feature1 Feature2 Feature3 Feature4 Output 1 1 2 3 4 a 2 5 6 7 8 b 3 9 10 11 12 c 4 13 14 15 16 d 5 17 18 19 20 e 6 21 22 23 24 f 7 25 26 27 28 g 8 29 30 31 32 h 9 33 34 35 36 i 10 37 38 39 40 j The task is to estimate the Output of any future timestep based on the data from last 3 timesteps. Some input

How to use a pre-trained embedding matrix in tensorflow 2.0 RNN as initial weights in an embedding layer?

China☆狼群 提交于 2019-12-09 18:58:47
问题 I'd like to use a pretrained GloVe embedding as the initial weights for an embedding layer in an RNN encoder/decoder. The code is in Tensorflow 2.0. Simply adding the embedding matrix as a weights = [embedding_matrix] parameter to the tf.keras.layers.Embedding layer won't do it because the encoder is an object and I'm not sure now to effectively pass the embedding_matrix to this object at training time. My code closely follows the neural machine translation example in the Tensorflow 2.0

Varying sequence length in Keras without padding

淺唱寂寞╮ 提交于 2019-12-09 16:37:55
问题 I have a question regarding varying sequence lengths for LSTMs in Keras. I'm passing batches of size 200 and sequences of variable lengths (= x) with 100 features for each object in the sequence (=> [200, x, 100]) into a LSTM: LSTM(100, return_sequences=True, stateful=True, input_shape=(None, 100), batch_input_shape=(200, None, 100)) I'm fitting the model on the following randomly created matrices: x_train = np.random.random((1000, 50, 100)) x_train_2 = np.random.random((1000, 10,100)) As far

Wrong number of dimensions on model.fit

浪尽此生 提交于 2019-12-09 15:39:50
问题 I'm trying to run this SimpleRNN: model.add(SimpleRNN(init='uniform',output_dim=1,input_dim=len(pred_frame.columns))) model.compile(loss="mse", optimizer="sgd") model.fit(X=predictor_train, y=target_train, batch_size=len(pred_frame.index),show_accuracy=True) The error is on model.fit, as you can see below: File "/Users/file.py", line 1496, in Pred model.fit(X=predictor_train, y=target_train, batch_size=len(pred_frame.index),show_accuracy=True) File "/Library/Python/2.7/site-packages/keras