I am trying to build intrusion detection LSTM and auto encoders. However I am not able to understand why repeat_vector_58 requires ndim=3. I am not able to figure this out. Below is my code:
x_train.shape: (8000, 1, 82)
x_test.shape: (2000, 1, 82)
x_train = np.reshape(trainX, (trainX.shape[0], 1, trainX.shape[1]))
x_test = np.reshape(testT, (testT.shape[0], 1, testT.shape[1]))
start = time.time()
model = Sequential()
model.add(LSTM(128, activation='relu',recurrent_dropout=0.5,return_sequences=True,input_dim=82))
model.add(RepeatVector(82))
model.add(Dropout(0.3))
model.add(LSTM(64, activation='relu',recurrent_dropout=0.5,return_sequences=False))
model.add(Dropout(0.3))
model.add(TimeDistributed(Dense(1,activation='softmax')))
ValueError: Input 0 is incompatible with layer repeat_vector_58: expected ndim=2, found ndim=3
LSTM layer expects 3-dimensional input because it is recurrent layer. The expected input is (batch_size, timesteps, input_dim)
.
The specification input_dim=82
expects 2-dim input but the expected input is 3-dim.
So the solution to your error is, changing input_dim=82
to input_shape=(82,1)
.
model = Sequential()
model.add(LSTM(128,activation='relu',recurrent_dropout=0.5,return_sequences=True,input_shape=(82,1)))