alexander-rakhlin / CNN-for-Sentence-Classification-in-Keras

Convolutional Neural Networks for Sentence Classification in Keras
MIT License
596 stars 205 forks source link

How to train multiclass documents data? #5

Closed shashankg7 closed 8 years ago

shashankg7 commented 8 years ago

Hi,

Thanks for releasing the code in keras, the other implementations are in torch and tensorflow and theano which currently I am not familiar with.

I have one question though, how can I train multiclass documents with this model? Currently it seems to support only binary class data?

alexander-rakhlin commented 8 years ago

Thanks for the interest. I suggest softmax in last layers and categorical_crossentropy as loss:

model.add(Dense(num_classes))
model.add(Activation("softmax"))
model.compile(loss="categorical_crossentropy", optimizer="rmsprop", metrics=["accuracy"])
worksduke commented 11 months ago

来信收悉。