bjornsing
bjornsing

Reputation: 332

How can I implement a 1D CNN in front of my LSTM network

At the moment I reshape my X_train like this:

X_train = input.reshape(1,1,12)
model = Sequential()
model.add(LSTM(100,input_shape=(1, 12)))
model.add(Dense(100, activation='relu'))
model.add(Dropout(0.5))
model.add(Dense(9, activation='sigmoid'))

Model image

But now I am thinking of implementing a 1D CNN in front of this LSTM layer. Does anybody know how this should be done?

Upvotes: 1

Views: 331

Answers (1)

MeanStreet
MeanStreet

Reputation: 1287

You have a keras.layers.Conv1D (see doc) that you can applay to your network input.

If you input is of shape (1,1,12) and you apply K filters, you'll get an output of shape (1,1,K): so you might want to swap it to (1,12,1) to place the steps in 2nd position (check doc).

Note that model.summary() might help you debug the input and output shapes of your network.

Upvotes: 1

Related Questions