Skip to content

Commit

Permalink
add fasttext
Browse files Browse the repository at this point in the history
  • Loading branch information
captain committed Aug 11, 2018
1 parent c4fa279 commit 47794ae
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 89 deletions.
167 changes: 91 additions & 76 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class DefaultConfig(object):
列出所有的参数,只根据模型需要获取参数
'''
env = 'default' # visdom环境
model = 'TextCNN' # 使用的模型,名字必须与models/__init__.py中的名字一致
model = 'FastText' # 使用的模型,名字必须与models/__init__.py中的名字一致

# 数据集参数
# train_data_path = '/data/yujun/datasets/daguanbei_data/new_train_set.csv'
Expand All @@ -30,13 +30,13 @@ class DefaultConfig(object):

vocab_size = 10000 # 词库规模,配置中写的值没有意义,实际是预处理阶段获取
label_size = 19 # 分类类别数
batch_size = 128
batch_size = 16
max_text_len = 1000 # 之后会处理成变长的,这里的设置没有意义
text_type = 'word' # or 'article'

# 训练参数
# cuda = True
lr1 = 2e-3 # learning rate
lr1 = 1e-3 # learning rate
lr2 = 0 # embedding层的学习率
min_lr = 1e-5 # 当学习率低于这个值时,就退出训练
# lr_decay = 0.8 # 当一个epoch的损失开始上升时,lr = lr*lr_decay
Expand Down
1 change: 1 addition & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ def main(**kwargs):
lr1 *= 0.8
lr2 = 2e-4 if lr2 == 0 else lr2 * 0.8
optimizer = model.get_optimizer(lr1, lr2, args.weight_decay)
print('* model lr:{} emb lr:{}'.format(lr1, lr2))


def val(model, dataset, args):
Expand Down
Loading

0 comments on commit 47794ae

Please sign in to comment.