使用 Keras 嵌入层的词嵌入情感分析

我需要对我的模型结果进行一些说明。

这是我的用例:

  • 决定标准普尔 500 指数公司的评价是负面还是正面。我使用了一个爬取的数据集。 (数据集被标记(0 - 正,1 - 负)、标记化和清理)。

为了理解模型和我的方法,这里有一些重要的信息:

# Constants
NB_WORDS = 44000  # Parameter indicating the number of words we'll put in the dictionary
VAL_SIZE = 1000  # Size of the validation set
NB_START_EPOCHS = 10  # Number of epochs we usually start to train with
EPOCH_ITER = list(range(0,11)) # For stepwise evaluating the accuracy metrics for 10 epochs
BATCH_SIZE = 512  # Size of the batches used in the mini-batch gradient descent
MAX_LEN = 267  # Maximum number of words in a sequence (review)
REV_DIM = 300 # Number of dimensions of the indeed review word embeddings --> most common Mikolow et al.,2013


# Modeling
emb_model = models.Sequential()

emb_model.add(layers.Embedding(NB_WORDS,REV_DIM,input_length=MAX_LEN)) 
# Embedding layer is first hidden layer

"""
Embedding Layer (
input_length = no. of words in vocabularly;
output_dim = dimensionality; 
max_length = length of largest review
)
"""
                                                                            
emb_model.add(layers.flatten()) 
# flatten Layers are reshaping tensor to 1-D array

emb_model.add(layers.Dense(2,activation='softmax'))
# Is the regular deeply connected neural network layer. It is most common and 
# frequently used layer. Dense layer does the below operation on the input and return the output.
# Operation := output = activation(dot(input,kernel) + bias)
# further see: https://www.tutorialspoint.com/keras/keras_dense_layer.htm#:~:text=Advertisements,input%20and%20return%20the%20output.
# Defines the output size in our case 2,hence positive or negative (0 or 1)

emb_model.summary()

我已经做了一些解释。但由于我是初学者,我确实需要更多信息/解释/提示,尤其是关于如何以及为何改进我的模型。

这是我的结果:

使用 Keras 嵌入层的词嵌入情感分析

使用 Keras 嵌入层的词嵌入情感分析

tchenfengm 回答:使用 Keras 嵌入层的词嵌入情感分析

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/302399.html

大家都在问