lstm

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

时光总嘲笑我的痴心妄想 提交于 2019-12-06 03:55:57
问题 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

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

僤鯓⒐⒋嵵緔 提交于 2019-12-06 03:17:25
问题 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

ConcatOp : Dimensions of inputs should match

邮差的信 提交于 2019-12-06 03:15:54
问题 I'm developing a deep learning model with tensor flow and python: First, using CNN layers, get features. Second, reshaping the feature map, I want to use LSTM layer. However, a error with not-matching dimension... ConcatOp : Dimensions of inputs should match: shape[0] = [71,48] vs. shape[1] = [1200,24] W_conv1 = weight_variable([1,conv_size,1,12]) b_conv1 = bias_variable([12]) h_conv1 = tf.nn.relu(conv2d(x_image, W_conv1)+ b_conv1) h_pool1 = max_pool_1xn(h_conv1) W_conv2 = weight_variable([1

Keras ConvLSTM2D: ValueError on output layer

筅森魡賤 提交于 2019-12-06 02:55:44
问题 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

How should we pad text sequence in keras using pad_sequences?

落爺英雄遲暮 提交于 2019-12-05 21:35:27
问题 I have coded a sequence to sequence learning LSTM in keras myself using the knowledge gained from the web tutorials and my own intuitions. I converted my sample text to sequences and then padded using pad_sequence function in keras. from keras.preprocessing.text import Tokenizer,base_filter from keras.preprocessing.sequence import pad_sequences def shift(seq, n): n = n % len(seq) return seq[n:] + seq[:n] txt="abcdefghijklmn"*100 tk = Tokenizer(nb_words=2000, filters=base_filter(), lower=True,

End-to-End Memory Networks 端到端的记忆网络 精读

廉价感情. 提交于 2019-12-05 20:36:47
一、记忆网络 记忆网络:通过设计记忆模块 存储序列模型的中间结果 以防丢失信息 意义:可以解决RNN中信息丢失问题 二、RNN序列以及GRU和LSTM 1、传统RNN方法 2、GRU方法:多了两个门 3、LSTM多了一个记忆单元ct 二、前期知识储备 了解Memory NetWork 参考链接:https://arxiv.org/abs/1410.3916 https://zhuanlan.zhihu.com/p/29590286 来源: https://www.cnblogs.com/cola-1998/p/11945803.html

keras cnn_lstm input layer not accepting 1-D input

谁说我不能喝 提交于 2019-12-05 20:22:23
I have sequences of long 1_D vectors (3000 digits) that I am trying to classify. I have previously implemented a simple CNN to classify them with relative success: def create_shallow_model(shape,repeat_length,stride): model = Sequential() model.add(Conv1D(75,repeat_length,strides=stride,padding='same', input_shape=shape, activation='relu')) model.add(MaxPooling1D(repeat_length)) model.add(Flatten()) model.add(Dense(1, activation='sigmoid')) model.compile(loss='binary_crossentropy', optimizer='rmsprop', metrics=['accuracy']) return model However I am looking to improve the performance by

Keras LSTM: Error when checking model input dimension

淺唱寂寞╮ 提交于 2019-12-05 18:45:45
I am a new user of keras, and trying to implement a LSTM model. For test I declared the model like below, but it fails because of difference of input dimension. Although I found similar problems in this site, I could not find my mistakes by myself. ValueError: Error when checking model input: expected lstm_input_4 to have 3 dimensions, but got array with shape (300, 100) My environment python 3.5.2 keras 1.2.0 (Theano) Code from keras.layers import Input, Dense from keras.models import Sequential from keras.layers import LSTM from keras.optimizers import RMSprop, Adadelta from keras.layers

Tensorflow save final state of LSTM in dynamic_rnn for prediction

 ̄綄美尐妖づ 提交于 2019-12-05 18:35:06
I want to save the final state of my LSTM such that it's included when I restore the model and can be used for prediction. As explained below, the Saver only has knowledge of the final state when I use tf.assign . However, this throws an error (also explained below). During training I always feed the final LSTM state back into the network, as explained in this post . Here are the important parts of the code: When building the graph: self.init_state = tf.placeholder(tf.float32, [ self.n_layers, 2, self.batch_size, self.n_hidden ]) state_per_layer_list = tf.unstack(self.init_state, axis=0) rnn

Keras Stateful LSTM fit_generator how to use batch_size > 1

你。 提交于 2019-12-05 18:24:23
I want to train an stateful LSTM network using the functional API in Keras. The fit method is fit_generator . I am able to train it, using: batch_size = 1 My Input layer is: Input(shape=(n_history, n_cols),batch_shape=(batch_size, n_history, n_cols), dtype='float32', name='daily_input') The generator is as follows: def training_data(): while 1: for i in range(0,pdf_daily_data.shape[0]-n_history,1): x = f(i)() # f(i) shape is (1, n_history, n_cols) y = y(i) yield (x,y) And then the fit is: model.fit_generator(training_data(), steps_per_epoch=pdf_daily_data.shape[0]//batch_size,... This works