recurrent-neural-network

Define custom LSTM with multiple inputs

空扰寡人 提交于 2020-03-04 04:37:58
问题 Following the tutorial writing custom layer, I am trying to implement a custom LSTM layer with multiple input tensors. I am providing two vectors input_1 and input_2 as a list [input_1, input_2] as suggested in the tutorial. The single input code is working but when I change the code for multiple inputs, its throwing the error, self.kernel = self.add_weight(shape=(input_shape[0][-1], self.units), TypeError: 'NoneType' object is not subscriptable. What change I have to do to get rid of the

Strange behaviour sequence to sequence learning for variable length sequences

纵然是瞬间 提交于 2020-03-03 07:45:10
问题 I am training a sequence to sequence model for variable length sequences with Keras, but I am running into some unexpected problems. It is unclear to me whether the behaviour I am observing is the desired behaviour of the library and why it would be. Model Creation I've made a recurrent model with an embeddings layer and a GRU recurrent layer that illustrates the problem. I used mask_zero=0.0 for the embeddings layer instead of a masking layer, but changing this doesn't seem to make a

RNN model predicting only one class?

心不动则不痛 提交于 2020-02-07 05:42:24
问题 I am trying to use GloVe embeddings to train a rnn model based on this article. I have a labeled data: text(tweets) on one column, labels on another (hate, offensive or neither). However the model seems to predict only one class in the result. This is the LSTM model: model = Sequential() hidden_layer = 3 gru_node = 32 # model embedding matrix here.... for i in range(0,hidden_layer): model.add(GRU(gru_node,return_sequences=True, recurrent_dropout=0.2)) model.add(Dropout(dropout)) model.add(GRU

How to train the self-attention model?

前提是你 提交于 2020-01-25 09:25:08
问题 I understand the whole structure of transformer as in the figure below, but one thing confused me is the bottom of the decoder part which has the input of right-shifting outputs. For example, when training the model with a pair of two language sentences, let's say the input is the sentence "I love you", and the corresponding French is the "je t'aime". How does the model train? So the input of encoder is "I love you", for the decoder, there are two things, one is "je t'aime" which should be

Keras sequence models - how to generate data during test/generation?

吃可爱长大的小学妹 提交于 2020-01-25 08:14:09
问题 Is there a way to use the already trained RNN (SimpleRNN or LSTM) model to generate new sequences in Keras? I'm trying to modify an exercise from the Coursera Deep Learning Specialization - Sequence Models course, where you train an RNN to generate dinosaurus's names. In the exercise you build the RNN using only numpy, but I want to use Keras. One of the problems is different lengths of the sequences (dino names), so I used padding and set sequence length to the max size appearing in the

Tensorflow LSTM Error (ValueError: Shapes must be equal rank, but are 2 and 1 )

流过昼夜 提交于 2020-01-24 12:43:26
问题 I know this questions have been asked many times but i am kind of new to tensorflow and none of the previous threads could solve my issue. I am trying to implement a LSTM for series of sensor data to classify data. I want my data be classified as 0 or 1 so its a binary classifier. I have over all 2539 samples which each of them have 555 time_steps and each time_step carries 9 features so my input has shape (2539, 555, 9) and for each sample and i have a label array which hold the value 0 or 1

Tensorflow dynamic_rnn deprecation

半世苍凉 提交于 2020-01-23 01:43:07
问题 It seems that the tf.nn.dynamic_rnn has been deprecated: Warning: THIS FUNCTION IS DEPRECATED. It will be removed in a future version. Instructions for updating: Please use keras.layers.RNN(cell), which is equivalent to this API I have checked out keras.layers.RNN(cell) and it says that it can use masking which I assume can act as a replacement for dynamic_rnn 's sequence_length parameter? This layer supports masking for input data with a variable number of timesteps. To introduce masks to

How is the input tensor for TensorFlow's tf.nn.dynamic_rnn operator structured?

天大地大妈咪最大 提交于 2020-01-23 01:04:10
问题 I am trying to write a language model using word embeddings and recursive neural networks in TensorFlow 0.9.0 using the tf.nn.dynamic_rnn graph operation, but I don't understand how the input tensor is structured. Let's say I have a corpus of n words. I embed each word in a vector of length e , and I want my RNN to unroll to t time steps. Assuming I use the default time_major = False parameter, what shape would my input tensor [batch_size, max_time, input_size] have? Maybe a specific tiny

Training and Testing accuracy not increasing for a CNN followed by a RNN for signature verification

孤街浪徒 提交于 2020-01-15 05:32:45
问题 I'm currently working on online signature verification. The dataset has a variable shape of (x, 7) where x is the number of points a person used to sign their signature. I have the following model: model = Sequential() #CNN model.add(Conv1D(filters=64, kernel_size=3, activation='sigmoid', input_shape=(None, 7))) model.add(MaxPooling1D(pool_size=3)) model.add(Conv1D(filters=64, kernel_size=2, activation='sigmoid')) #RNN model.add(Masking(mask_value=0.0)) model.add(LSTM(8)) model.add(Dense(2,

How to Feed Batched Sequences of Images through Tensorflow conv2d

纵然是瞬间 提交于 2020-01-14 10:43:49
问题 This seems like a trivial question, but I've been unable to find the answer. I have batched sequences of images of shape: [batch_size, number_of_frames, frame_height, frame_width, number_of_channels] and I would like to pass each frame through a few convolutional and pooling layers. However, TensorFlow's conv2d layer accepts 4D inputs of shape: [batch_size, frame_height, frame_width, number_of_channels] My first attempt was to use tf.map_fn over axis=1, but I discovered that this function