如何使用CNN Tensorflow从电影评论中对情感和流派进行分类 [英] How to classify both sentiment and genres from movie reviews using CNN Tensorflow

查看:554
本文介绍了如何使用CNN Tensorflow从电影评论中对情感和流派进行分类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试对电影评论的情绪进行分类,并根据评论本身来预测电影的类型.现在,情感是一个二进制分类问题,因为流派可能是多标签分类问题.

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.

更重要的是,我想使用Tensorflow CNN进行此分类.我的问题是构造y_label并训练数据,以使输出帮助我检索情绪和体裁. 例如,数据Y标签:[[0,1],[0,1,0,1,0]]用于表示情绪为负面,情绪为讽刺和愤怒

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?

推荐答案

基本上,在将CNN输出的大小调整为1x1xN形式的CNN的最后一层时,添加两个前馈神经网络.因此,如果您有一个简单的分类问题,可以将CNN的输出馈入前馈神经网络,现在在这种情况下,您将拥有其中两个网络.因此,为了基本完成此操作,您将具有以下内容:

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输出--- feed --->分类器#1
  • CNN输出--- feed --->分类器#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 

因此,您将使用优化器最小化" loss.

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

这篇关于如何使用CNN Tensorflow从电影评论中对情感和流派进行分类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆