Model Definition
After preprocessing our text data, the next step is to define the architecture of our text classification model.
from keras.models import Sequential
from keras.layers import Embedding, LSTM, Dense
embedding_dim = 50 # Adjust based on your preferences
model = Sequential()
model.add(Embedding(input_dim=max_words, output_dim=embedding_dim, input_length=max_len))
model.add(LSTM(100))
model.add(Dense(6, activation='softmax'))
# Compile the model
model.compile(optimizer='adam', loss='categorical_crossentropy', metrics=['accuracy'])Last updated