0

I'm trying to build an LSTM autoencoder as shown here.
My code:

from keras.layers import Input, LSTM, RepeatVector
from keras.models import Model

inputs = Input(shape=(window_length, input_dim))
encoded = LSTM(latent_dim)(inputs)

decoded = RepeatVector(window_length)(encoded)
decoded = LSTM(input_dim, return_sequences=True)(decoded)

model = Model(inputs, decoded)
model.fit(batch_size=512)

The shape of the dataset is: (rows, window_length, input_dim).
When I try to call fit() I get this error:

ValueError: Cannot feed value of shape (512, 221) for Tensor u'lstm_2_target:0', which has shape '(?, ?, ?)'

This model it's really simple, I don't understand what is the problem.

EDIT
Model summary:

Layer (type)                 Output Shape              Param #   
=================================================================
input_1 (InputLayer)         (None, 10, 221)           0         
_________________________________________________________________
lstm_1 (LSTM)                (None, 128)               179200    
_________________________________________________________________
repeat_vector_1 (RepeatVecto (None, 10, 128)           0         
_________________________________________________________________
lstm_2 (LSTM)                (None, 10, 221)           309400    
=================================================================
Total params: 488,600
Trainable params: 488,600
Non-trainable params: 0
Alessandro
  • 742
  • 1
  • 10
  • 34

1 Answers1

0

If the code was run exactly as above, it probably needs to be compiled:

model.compile(optimizer='rmsprop', loss='mse', metrics=['acc', 'cosine_proximity'])
Fosa
  • 562
  • 5
  • 15