lstm

In what order are weights saved in a LSTM kernel in Tensorflow

。_饼干妹妹 提交于 2019-12-04 21:13:21
I looked into the saved weights for a LSTMCell in Tensorflow. It has one big kernel and bias weights. The dimensions of the kernel are (input_size + hidden_size)*(hidden_size*4) Now from what I understand this is encapsulating 4 input to hidden layer affine transforms as well as 4 hidden to hidden layer transforms. So there should be 4 matrices of size input_size*hidden_size and 4 of size hidden_size*hidden_size Can someone tell me or point me to the code where TF saves these, so I can break the kernel matrix into smaller matrices. c2huc2hu The weights are combined as mentioned in the other

Keras LSTM training data format

久未见 提交于 2019-12-04 20:13:59
问题 I am trying to use LSTM neural network (using Keras) to predict opponent's next move in the game Rock-Paper-Scissor. I have encode the inputs as Rock: [1 0 0], Paper: [0 1 0], Scissor: [0 0 1]. Now I want to train the neural network but I am a bit confused of the data structure of my training data. I have stored an opponent's game history in a .csv file with the following structure: 1,0,0 0,1,0 0,1,0 0,0,1 1,0,0 0,1,0 0,1,0 0,0,1 1,0,0 0,0,1 And I am trying to use every 5th data as my

Keras - Restore LSTM hidden state for a specific time stamp

邮差的信 提交于 2019-12-04 20:13:51
This question is in continue to ( LSTM - Making predictions on partial sequence ). As described in the previous question I've trained a stateful LSTM model for binary classification with batches of 100 samples/labels like so: [Feature 1,Feature 2, .... ,Feature 3][Label 1] [Feature 1,Feature 2, .... ,Feature 3][Label 2] ... [Feature 1,Feature 2, .... ,Feature 3][Label 100] Model Code: def build_model(num_samples, num_features, is_training): model = Sequential() opt = optimizers.Adam(lr=0.0005, beta_1=0.9, beta_2=0.999, epsilon=1e-08, decay=0.0001) batch_size = None if is_training else 1

How can we define one-to-one, one-to-many, many-to-one, and many-to-many LSTM neural networks in Keras? [duplicate]

六眼飞鱼酱① 提交于 2019-12-04 19:33:16
This question already has answers here : Many to one and many to many LSTM examples in Keras (2 answers) Closed last year . I am reading this article (The Unreasonable Effectiveness of Recurrent Neural Networks) and want to understand how to express one-to-one, one-to-many, many-to-one, and many-to-many LSTM neural networks in Keras. I have read a lot about RNN and understand how LSTM NNs work, in particular vanishing gradient, LSTM cells, their outputs and states, sequence output and etc. However, I have trouble expressing all these concepts in Keras. To start with I have created the

Keras train_on_batch loss/accuracy 0

喜你入骨 提交于 2019-12-04 19:03:47
问题 I am using a big dataset, and so I'm trying to use train_on_batch(or fit with epoch = 1) model = Sequential() model.add(LSTM(size,input_shape=input_shape,return_sequences=False)) model.add(Dense(output_dim)) model.add(Activation('softmax')) model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=["accuracy"]) for e in range(nb_epoch): for batch_X, batch_y in batches: model.train_on_batch(batch_X,batch_y) # or # model.fit(batch_X,batch_y,batch_size=batch_size,nb_epoch=1

Keras - Input a 3 channel image into LSTM

谁说我不能喝 提交于 2019-12-04 19:00:42
问题 I have read a sequence of images into a numpy array with shape (7338, 225, 1024, 3) where 7338 is the sample size, 225 are the time steps and 1024 (32x32) are flattened image pixels, in 3 channels (RGB). I have a sequential model with an LSTM layer: model = Sequential() model.add(LSTM(128, input_shape=(225, 1024, 3)) But this results in the error: Input 0 is incompatible with layer lstm_1: expected ndim=3, found ndim=4 The documentation mentions that the input tensor for LSTM layer should be

How to get the output shape of a layer in Keras?

我的梦境 提交于 2019-12-04 18:40:14
问题 I have the following code in Keras (Basically I am modifying this code for my use) and I get this error: 'ValueError: Error when checking target: expected conv3d_3 to have 5 dimensions, but got array with shape (10, 4096)' Code: from keras.models import Sequential from keras.layers.convolutional import Conv3D from keras.layers.convolutional_recurrent import ConvLSTM2D from keras.layers.normalization import BatchNormalization import numpy as np import pylab as plt from keras import layers # We

4D input in LSTM layer in Keras

心不动则不痛 提交于 2019-12-04 18:14:17
I have data with a shape of (10000, 20, 15, 4) where num samples = 10000 , num series in time = 20 , height = 15 , weight = 4 . So I have table 15x4 which is distributed over time. Here is the model I want to train it over this data: ... model.add((LSTM(nums-1,return_sequences=True,input_shape=(20,15,4), activation='relu'))) model.add((LSTM(nums-1,return_sequences=False,input_shape=(20,15,4), activation='tanh'))) model.add(Dense(15,activation='relu')) ... However, I get the following error: ValueError: Input 0 is incompatible with layer lstm_1: expected ndim=3, found ndim=4 How do I define a

LSTM model just repeats the past in forecasting time series

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-04 15:31:18
I want to predict one output variable from nine input variables. This data is also a time series and the goal is to predict the output variable 2 timesteps ahead. I normalised all data using mean normalisation and added some features so now the data look like this: weekday (weekend vs weekday) hour (f_real - 50)*70 ACE [Mwh] \ 0 -1.579094 -1.341627 0.032171 2.017604 1 -1.579094 -0.447209 0.032171 -0.543702 2 -1.579094 0.447209 0.037651 0.204731 3 -1.579094 1.341627 0.043130 -0.601538 4 -1.579094 -1.341627 0.021211 11.759046 IGCC [Mwh] SRE [Mwh] TertCalls [Mwh] Imbalance [Mwh] Time 0 0.257560 5

What is the architecture behind the Keras LSTM Layer implementation?

那年仲夏 提交于 2019-12-04 14:42:18
How does the input dimensions get converted to the output dimensions for the LSTM Layer in Keras? From reading Colah's blog post , it seems as though the number of "timesteps" (AKA the input_dim or the first value in the input_shape ) should equal the number of neurons, which should equal the number of outputs from this LSTM layer (delineated by the units argument for the LSTM layer). From reading this post , I understand the input shapes. What I am baffled by is how Keras plugs the inputs into each of the LSTM "smart neurons". Keras LSTM reference Example code that baffles me: model =