giuseppebonaccorso / Reuters-21578-Classification

Text classification with Reuters-21578 datasets using Gensim Word2Vec and Keras LSTM
http://www.bonaccorso.eu
MIT License
43 stars 41 forks source link

Loss function #3

Closed mkcedward closed 7 years ago

mkcedward commented 7 years ago

Thank you for your great sample. It is good tutorial for classifying text.

Would like to know about the loss function of LSTM model. For multiclass problem, categorical_crossentropy should be used while Why do you use binary_crossentropy ?

giuseppebonaccorso commented 7 years ago

In this example, there's a single category without onehot encoding, therefore the output layer is a single sigmoid and the loss is binary cross-entropy.

If you use more categories, categorical_crossentropy is the best choice, but the output layer must be softmax with onehot encoding for all categories.