mirror of
https://github.com/apachecn/ailearning.git
synced 2026-02-10 13:55:05 +08:00
优化学习率,效果更加平稳
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 26 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 24 KiB |
@@ -15,7 +15,7 @@ class Config(object):
|
||||
# 根据前六个字预测第七个字
|
||||
max_len = 6
|
||||
batch_size = 512
|
||||
learning_rate = 0.005
|
||||
learning_rate = 0.0005
|
||||
pre_num = 3
|
||||
MAX_SEQUENCE_LENGTH = 1000 # 每个文本或者句子的截断长度,只保留1000个单词
|
||||
EMBEDDING_DIM = 60 # 词向量维度
|
||||
|
||||
@@ -163,7 +163,7 @@ class EmotionModel(object):
|
||||
preds = Dense(self.pre_num, activation='softmax')(x)
|
||||
self.model = Model(sequence_input, preds)
|
||||
# 设置优化器
|
||||
optimizer = Adam(lr=self.config.learning_rate)
|
||||
optimizer = Adam(lr=self.config.learning_rate, beta_1=0.95, beta_2=0.999,epsilon=1e-08)
|
||||
self.model.compile(optimizer=optimizer, loss='categorical_crossentropy', metrics=['accuracy'])
|
||||
self.model.summary()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user