Reputation: 77
I have coded LSTM as below. Now I would like to compare the performance of the RNN and LSTM. Actually, I know LSTM is a type of RNN. But how can I take the results from RNN on Keras? I could not find a proper RNN code example on Keras.
model = Sequential()
model.add(LSTM(15, input_shape=(max_fixation_length, feature_size,), return_sequences=True))
model.add(Flatten())
model.add(Dense(1, activation='sigmoid'))
# Compile model
model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])enter code here
Also, I have read this link Keras simple RNN implementation . However, I could not run it. Because Keras has given this error "undefined name 'SimpleRNN'"
Upvotes: 0
Views: 592
Reputation: 115
Simply first you need to import necessary libraries. First of all preprocess your data, then build a model, train your dataset finally you can do prediction part
Upvotes: 0
Reputation: 3727
I understand that the fundamental problem that you are facing is "how to train RNNs (LSTM is a kind of RNN afterall) using Keras". I would point you to this excellent collection of sample codes in Keras Github repository.
This is a simple script showing how to train LSTMs. You should be able to run this script as is. To answer why you are getting that specific error undefined name 'SimpleRNN'
, it seems you forgot to import SimpleRNN
. Try following the script/link I shared and let me know if it works for you :)
Upvotes: 2