Code:

model = Sequential() model.add(Embedding(max_features, 32)) model.add(SpatialDropout1D(0.2)) model.add(LSTM(100, dropout=0.2, recurrent_dropout=0.2)) model.add(Dense(num_classes, activation="sigmoid")) model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['accuracy']) model.fit(x_train, y_train, batch_size=256, epochs=15, validation_data=(x_test, y_test), verbose=2) scores = model.evaluate(x_test, y_test, batch_size=256) 

Are there more suitable / efficient neural network architecture options for text classification?

    1 answer 1

    The first thing that catches your eye is the discrepancy between the chosen activation function and the loss (error) function. The sigmoid activation function is used for binary classification and is used in conjunction with the loss function: binary_crossentropy .

    If the classification result can be more than two (3+) values, then softmax should be used as an activation function, and categorical_crossentropy as a loss.

    The most suitable architecture is the one that gives you the best results for you and satisfies all your boundary conditions.