0
votes

I am unsure if I need to add a Dense input layer before adding LSTM layers in my model. Forexample, with the following model:

# Model
model = Sequential()
model.add(LSTM(128, input_shape=(train_x.shape[1], train_x.shape[2])))
model.add(Dense(5, activation="linear"))

Will the LSTM layer be the input layer, and the Dense layer the output layer (meaning no hidden layers)? Or does Keras create an input layer meaning the LSTM layer will be a hidden layer?

2

2 Answers

0
votes

You don't need too. It depends on what you want to accomplish.

Check here some cases.

In your case, yes the LSTm will be the first layer and the Dense layer will be the output layer.

0
votes

The current configuration is okay for simple examples. Everything is based on what you want to get as results. The model and layers subject to change based on the target goal. So, if the model is complex, you can make mix model with different layers and shapes. See reference.

Mix model layering