lstm

Keras LSTM: a time-series multi-step multi-features forecasting - poor results

梦想的初衷 提交于 2019-12-04 10:45:03
问题 I have a time series dataset containing data from a whole year (date is the index). The data was measured every 15 min (during whole year) which results in 96 timesteps a day. The data is already normalized. The variables are correlated. All the variables except the VAR are weather measures. VAR is seasonal in a day period and in a week period (as it looks a bit different on weekend, but more less the same every weekend). VAR values are stationary. I would like to predict values of VAR for

Tensorflow: Using weights trained in one model inside another, different model

淺唱寂寞╮ 提交于 2019-12-04 09:16:17
I'm trying to train an LSTM in Tensorflow using minibatches, but after training is complete I would like to use the model by submitting one example at a time to it. I can set up the graph within Tensorflow to train my LSTM network, but I can't use the trained result afterward in the way I want. The setup code looks something like this: #Build the LSTM model. cellRaw = rnn_cell.BasicLSTMCell(LAYER_SIZE) cellRaw = rnn_cell.MultiRNNCell([cellRaw] * NUM_LAYERS) cell = rnn_cell.DropoutWrapper(cellRaw, output_keep_prob = 0.25) input_data = tf.placeholder(dtype=tf.float32, shape=[SEQ_LENGTH, None, 3]

Keras ConvLSTM2D: ValueError on output layer

不打扰是莪最后的温柔 提交于 2019-12-04 08:30:45
I am trying to train a 2D convolutional LSTM to make categorical predictions based on video data. However, my output layer seems to be running into a problem: "ValueError: Error when checking target: expected dense_1 to have 5 dimensions, but got array with shape (1, 1939, 9)" My current model is based off of the ConvLSTM2D example provided by Keras Team. I believe that the above error is the result of my misunderstanding the example and its basic principles. Data I have an arbitrary number of videos, where each video contains an arbitrary number of frames. Each frame is 135x240x1 (color

Stateful LSTM and stream predictions

99封情书 提交于 2019-12-04 08:27:57
问题 I've trained an LSTM model (built with Keras and TF) on multiple batches of 7 samples with 3 features each, with a shape the like below sample (numbers below are just placeholders for the purpose of explanation), each batch is labeled 0 or 1: Data: [ [[1,2,3],[1,2,3],[1,2,3],[1,2,3],[1,2,3],[1,2,3],[1,2,3]] [[1,2,3],[1,2,3],[1,2,3],[1,2,3],[1,2,3],[1,2,3],[1,2,3]] [[1,2,3],[1,2,3],[1,2,3],[1,2,3],[1,2,3],[1,2,3],[1,2,3]] ... ] i.e: batches of m sequences, each of length 7, whose elements are

Seq2Seq model learns to only output EOS token (<\\s>) after a few iterations

烈酒焚心 提交于 2019-12-04 08:17:35
I am creating a chatbot trained on Cornell Movie Dialogs Corpus using NMT . I am basing my code in part from https://github.com/bshao001/ChatLearner and https://github.com/chiphuyen/stanford-tensorflow-tutorials/tree/master/assignments/chatbot During training, I print a random output answer fed to the decoder from the batch and the corresponding answer that my model predicts to observe the learning progress. My issue: After only about 4 iterations of training, the model learns to output the EOS token ( <\s> ) for every timestep. It always outputs that as its response (determined using argmax

Correct way to split data to batches for Keras stateful RNNs

折月煮酒 提交于 2019-12-04 07:28:46
As the documentation states the last state for each sample at index i in a batch will be used as initial state for the sample of index i in the following batch does it mean that to split data to batches I need to do it the following way e.g. let's assume that I am training a stateful RNN to predict the next integer in range(0, 5) given the previous one # batch_size = 3 # 0, 1, 2 etc in x are samples (timesteps and features omitted for brevity of the example) x = [0, 1, 2, 3, 4] y = [1, 2, 3, 4, 5] batches_x = [[0, 1, 2], [1, 2, 3], [2, 3, 4]] batches_y = [[1, 2, 3], [2, 3, 4], [3, 4, 5]] then

Using BI LSTM CTC Tensorflow Model in Android

只愿长相守 提交于 2019-12-04 06:25:40
问题 TL;DR, I want to know how to use a bi-lstm-ctc tensorflow model in an android application. I have succeeded in training my bi-lstm-ctc tensorflow model and now I want to use it for my handwriting recognition android application. Here's the part of the code that defines the graph I used: self.inputs = tf.placeholder(tf.float32, [None, None, network_config.num_features], name="input") self.labels = tf.sparse_placeholder(tf.int32, name="label") self.seq_len = tf.placeholder(tf.int32, [None],

How can I predict, forecast the value of the next day using Keras' LSTM?

此生再无相见时 提交于 2019-12-04 06:22:08
问题 I seek your advice to forecast the values after that using LSTM in Keras. I have x_train 62796 and x_test 15684 and I want to predict the values after that. Twenty data collections correspond to a day So, I set the look_back to 20. and 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,

PyTorch之—循环层,RNN,LSTM

爱⌒轻易说出口 提交于 2019-12-04 06:03:46
文章目录 一、RNN 循环神经网络 参数详解 二、LSTM 长短期记忆网络 参数详解 三、词嵌入 Embedding 小案例 使用RNN 训练模型 使用LSTM对文本进行词性标注 基于LSTM的词性标注模型 一、RNN 循环神经网络 参数详解 class torch.nn.RNN( args, * kwargs) 将一个多层的 Elman RNN,激活函数为 tanh 或者 ReLU ,用于输入序列。 对输入序列中每个元素,RNN每层的计算公式为 h t = tanh ⁡ ( w i h x t + b i h + w h h h t − 1 + b h h ) h_t=\tanh(w_{ih} x_t+b_{ih}+w_{hh} h_{t-1}+b_{hh}) h t ​ = tanh ( w i h ​ x t ​ + b i h ​ + w h h ​ h t − 1 ​ + b h h ​ ) h t h_t h t ​ 是时刻 t t t 的隐状态。 x t x_t x t ​ 是上一层时刻 t t t 的隐状态,或者是第一层在时刻 t t t 的输入。如果 nonlinearity=‘relu’, 那么将使用 relu 代替 tanh 作为激活函数。 RNN模型(公式)参数: weight_ih_l[k] – 第k层的 input-hidden 权重, 可学习,形状是

LSTM调参感悟

青春壹個敷衍的年華 提交于 2019-12-04 06:00:31
1. 一定要对数据进行归一化的预处理 train -= np.mean(train, axis = 0) # zero-center train /= np.std(train, axis = 0) # normalize test -= np.mean(test,axis=0) test /= np.std(test,axis=0) 2. 要用正交化初始化lstm 的weight值,如果可能的话,也可以将gate的bias设为0 def init_weight(self): for name, param in self.lstm.named_parameters(): if 'bias' in name: nn.init.constant(param, 0.0) print('\nbias init done') elif 'weight' in name: nn.init.orthogonal(param) print('\nweight init done') 3. 可以在定义的时候加入dropout,一般设为0.5 4. batch_size不要设太大,我设的8感觉就不错(当然也有人说要大些,见仁见智) 5.learning_rate一般取0.001 来源: CSDN 作者: xuzhaoqingbuaa 链接: https://blog.csdn.net