Francis
Francis

Reputation: 19

My LSTM model returns empty with no output and no parameters captured

I am building an LSTM model for sentiment analysis using a hotel review dataset. However, the model always returns empty with empty output and parameters each time I run the code.

I have followed many processes from cleaning to tokenization, vectorization, encoding, and padding.

enter image description here

See attached image.

I have followed the normal steps from cleaning, stopwords, tokenization, lemmatization, vectorization, padding.

I used the below code for the final model design:

# Design the model
model = Sequential()
model.add(Embedding(input_dim=len(vocab_int), output_dim=embedding_vector_length, input_length=max_sentence_length))
model.add(SimpleRNN(256, return_sequences=True, dropout=dropout, recurrent_dropout=dropout))
model.add(SimpleRNN(256, dropout=dropout, recurrent_dropout=dropout))
model.add(Dense(2, activation='softmax'))

model.compile(loss = 'categorical_crossentropy', optimizer='adam', metrics=['accuracy'])

print(model.summary())

I was expecting the built model with output layers and parameters but got nothing.

Upvotes: 0

Views: 97

Answers (1)

Ilya
Ilya

Reputation: 486

first why did you use categorical_crossentropy for binery classification ? use binary_crossentropy

second the input of embedding layer is none so your network is none

make sure you have :

print("X_train shape:", X_train.shape)
print("y_train shape:", y_train.shape) 

print("Vocabulary size:", len(vocab_int))
print("Embedding vector length:", embedding_vector_length)
print("Max sentence length:", max_sentence_length)
print("Input data shape:", X_train.shape)

and then comment it

Upvotes: 0

Related Questions