如何解决使用 Keras 嵌入层的词嵌入情感分析
我需要对我的模型结果进行一些说明。
这是我的用例:
为了理解模型和我的方法,这里有一些重要的信息:
# 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()
我已经做了一些解释。但由于我是初学者,我确实需要更多信息/解释/提示,尤其是关于如何以及为何改进我的模型。
这是我的结果:
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。