使用paddle进行酒店评论的情感分类11——超参数调节

超参数从来都是敏感的,参数的合理与否大大影响了模型的正确率。我将筛选过的数据集分为训练集与测试集,通过不断调节参数达到了相对能看的效果,参数如下

# 定义训练参数
epoch_num = 7
batch_size = 350 # 这里改为350

learning_rate = 0.0082 #这里改为0.0082
dropout_rate = 0.2 # 这里改为0.2
num_layers = 2  # 这里改为2
hidden_size = 150 # 这里改为150
embedding_size = 150 # 这里改为150
max_seq_len = 128 
vocab_size = len(word2id_freq)

经过训练,模型正确率达到79.14%,我要求不高,觉得不低了,就这样吧,总输出如下:

(paddle) D:\study_software\vscode\Microsoft VS Code\paddle\homework_sentiment_analysis>python __main__.py
Building prefix dict from the default dictionary ...
Loading model from cache C:\Users\ADMINI~1\AppData\Local\Temp\jieba.cache
Loading model cost 0.341 seconds.
Prefix dict has been built successfully.
there are totoally 16625 different words in the corpus
word [oov], its id 0, its word freq 10000000000
word [pad], its id 1, its word freq 10000000000
word 的, its id 2, its word freq 13306
word 了, its id 3, its word freq 4998
word 酒店, its id 4, its word freq 4240
word 是, its id 5, its word freq 3809
word 我, its id 6, its word freq 3337
word 房间, its id 7, its word freq 2852
word 很, its id 8, its word freq 2598
word 也, its id 9, its word freq 2103
word 在, its id 10, its word freq 2040
word 有, its id 11, its word freq 1653
word 不, its id 12, its word freq 1603
word 都, its id 13, its word freq 1591
word 还, its id 14, its word freq 1468
word 没有, its id 15, its word freq 1425
word 就, its id 16, its word freq 1423
word 住, its id 17, its word freq 1411
word 服务, its id 18, its word freq 1354
word 我们, its id 19, its word freq 1271
(array([[[  127],
        [   44],
        [  641],
        [   49],
        [   23],
        [ 1165],
        [ 2278],
        [ 2158],
        [  458],
        [   31],
        [ 1066],
        [   60],
        [   57],
        [14991],
        [  467],
        [   23],
        [   28],
        [  388],
        [    8],
        [ 1479],
        [  405],
        [ 1297],
        [   31],
        [   12],
        [ 1104],
        [   46],
        [  138],
        [ 1708],
        [    2],
        [    5],
        [ 3918],
        [   64],
        [  156],
        [   63],
        [  576],
        [  992],
        [ 3985],
        [   46],
        [  156],
        [  135]],

       [[  314],
        [   17],
        [  110],
        [  525],
        [   11],
        [  443],
        [   17],
        [   53],
        [  136],
        [  177],
        [  168],
        [   14],
        [   27],
        [  878],
        [   60],
        [  394],
        [   35],
        [   12],
        [  400],
        [  247],
        [  438],
        [  123],
        [  389],
        [  394],
        [   22],
        [  864],
        [ 1240],
        [ 1513],
        [   51],
        [   32],
        [    6],
        [  120],
        [  438],
        [   24],
        [ 1980],
        [  962],
        [ 4416],
        [ 2405],
        [    2],
        [    5]],

       [[   21],
        [    2],
        [  252],
        [ 1577],
        [  175],
        [  131],
        [    9],
        [   21],
        [   66],
        [ 4063],
        [  110],
        [  393],
        [   17],
        [   17],
        [    1],
        [    1],
        [    1],
        [    1],
        [    1],
        [    1],
        [    1],
        [    1],
        [    1],
        [    1],
        [    1],
        [    1],
        [    1],
        [    1],
        [    1],
        [    1],
        [    1],
        [    1],
        [    1],
        [    1],
        [    1],
        [    1],
        [    1],
        [    1],
        [    1],
        [    1]]], dtype=int64), array([[0],
       [0],
       [1]], dtype=int64))
W0803 22:30:03.772730 42020 gpu_resources.cc:119] Please NOTE: device: 0, GPU Compute Capability: 8.9, Driver API Version: 12.2, Runtime API Version: 11.7
W0803 22:30:03.995625 42020 gpu_resources.cc:149] device: 0, cuDNN Version: 8.4.
I0803 22:30:06.773458 42020 eager_method.cc:140] Warning:: 0D Tensor cannot be used as 'Tensor.numpy()[0]' . In order to avoid this problem, 0D Tensor will be changed to 1D numpy currently, but it's not correct and will be removed in release 2.6. For Tensor contain only one element, Please modify  'Tensor.numpy()[0]' to 'float(Tensor)' as soon as possible, otherwise 'Tensor.numpy()[0]' will raise error in release 2.6.
I0803 22:30:06.782459 42020 eager_method.cc:140] Warning:: 0D Tensor cannot be used as 'Tensor.numpy()[0]' . In order to avoid this problem, 0D Tensor will be changed to 1D numpy currently, but it's not correct and will be removed in release 2.6. For Tensor contain only one element, Please modify  'Tensor.numpy()[0]' to 'float(Tensor)' as soon as possible, otherwise 'Tensor.numpy()[0]' will raise error in release 2.6.
step 0, loss 0.693
TP: 105
FP: 24
TN: 172
FN: 49

Accuracy: 0.7914

你可能感兴趣的:(paddle,paddle,分类,数据挖掘)