Gossip Girl
Gossip Girl

Reputation: 23

Confusion about paramerters in Keras LSTM

model = Sequential()
model.add(LSTM(5, input_shape=(1, 30)))
model.add(Dense(1))
model.compile(loss='mean_squared_error', optimizer='rmsprop')
model.fit(trainX, trainY, epochs=15, batch_size=1, verbose=2)

Can someone tell me what the 5 in LSTM(5,...) and the 1 in Dense(1) do?

Thanks.

Upvotes: 0

Views: 259

Answers (3)

Lior Magen
Lior Magen

Reputation: 1573

Well you actually have it all in Keras' documentation

LSTM Dense

https://keras.io/layers/recurrent/

Their documentation is really intuitive and helpful, just use it.

Upvotes: 0

user239457
user239457

Reputation: 1876

  • The "5" in LSTM stands for "5" LSTM units
  • The "1" in Dense stands for "1" neuron in that layer

Link to the docs
LSTM
Dense

Upvotes: 1

A. Ada.
A. Ada.

Reputation: 54

  • The "5" in LSTM is the dimensionality of the output space, which means:

    • The input arrays have the shape defined in input_shape=(1, 30);
    • The output arrays have the shape (*, 5).
  • The "1" in Dense is the dimensionality of the output space too, which means:

    • The input arrays have the shape of the output in LSTM layer (*, 5);
    • The output arrays have the shape (*, 1).

Upvotes: 1

Related Questions