Keras LSTM dense layer multidimensional input -


i'm trying create keras lstm predict time series. x_train shaped 3000,15,10 (examples, timesteps, features), y_train 3000,15,1 , i'm trying build many many model (10 input features per sequence make 1 output / sequence).

the code i'm using this:

model = sequential()  model.add(lstm(     10,     input_shape=(15, 10),     return_sequences=true)) model.add(dropout(0.2))  model.add(lstm(     100,     return_sequences=true)) model.add(dropout(0.2)) model.add(dense(1, activation='linear')) model.compile(loss="mse", optimizer="rmsprop") model.fit(         x_train, y_train,         batch_size=512, nb_epoch=1, validation_split=0.05) 

however, can't fit model when using :

model.add(dense(1, activation='linear')) >> error when checking model target: expected dense_1 have 2 dimensions, got array shape (3000, 15, 1) 

or when formatting way:

model.add(dense(1)) model.add(activation("linear")) >> error when checking model target: expected activation_1 have 2 dimensions, got array shape (3000, 15, 1) 

i tried flattening model ( model.add(flatten()) ) before adding dense layer gives me valueerror: input 0 incompatible layer flatten_1: expected ndim >= 3, found ndim=2. confuses me because think data 3 dimensional, isn't it?

the code originated https://github.com/vict0rsch/deep_learning/tree/master/keras/recurrent

in case of keras < 2.0: need use timedistributed wrapper in order apply element-wise sequence.

in case of keras >= 2.0: dense layer applied element-wise default.


Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -