How to classify both sentiment and genres from movie reviews using CNN Tensorflow

自古美人都是妖i 提交于 2019-12-11 14:18:38

问题


I am trying to classify sentiment on movie review and predict the genres of that movie based on the review itself. Now Sentiment is a Binary Classification problem where as Genres can be Multi-Label Classification problem.

Another example to clarify the problem is classifying Sentiment of a sentence and also predicting whether the tone of the sentence is happy, sarcastic, sad, pitiful, angry or fearful.

More to that is, I want to perform this classification using Tensorflow CNN. My problem is in structuring the y_label and training the data such that the output helps me retrieve Sentiment as well as the genres. Eg Data Y Label: [[0,1],[0,1,0,1,0]] for sentiment as Negative and mood as sarcastic and angry

How do you suggest I tackle this?


回答1:


Basically at the final layer of the CNN as you've resized the CNN output to a form of 1x1xN, add two Feed-Forward Neural Networks. So if you have a simple classification problem you feed the output of the CNN into a Feed-Forward Neural Network, now in this case you'll have two of these networks. So in order to accomplish this basically you'll have the following:

  • CNN output ---feed---> Classifier#1
  • CNN output ---feed---> Classifier#2

Thus you'll have to separate classifications BUT you'll still have to backpropagate them so it will look something like this:

loss1 = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(prediction1, labels_1))
loss2 = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(prediction2, labels_2))

loss = loss1 + loss2 

So you'll "minimize" the loss with an optimizer.




回答2:


You can treat this as a multi-label problem, and append the sentiment and the tone labels together.

Now since the network has to predict multiple outputs (2 in this case) you need to use an activation function like sigmoid and not softmax. And your prediction can be made using tf.round(logits).



来源:https://stackoverflow.com/questions/45004514/how-to-classify-both-sentiment-and-genres-from-movie-reviews-using-cnn-tensorflo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!