forked from moon-hotel/TransformerClassification
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e7d0211
commit 1c718f7
Showing
1 changed file
with
32 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,32 @@ | ||
# TransformerClassification | ||
A Transformer Framework Based Classification Task | ||
|
||
## A Transformer Framework Based Classification Task | ||
|
||
### 一个基于Transformer Encoder网络结构的文本分类模型 | ||
|
||
|
||
|
||
## 1. 环境准备 | ||
* Python==3.6 | ||
* PyTorch==1.5.0 | ||
* torchtext==0.6.0 | ||
|
||
|
||
## 2. 使用方法 | ||
* STEP 1. 直接下载或克隆本项目 | ||
* STEP 2. 可自定义修改配置文件`config.py`中的配置参数,也可以保持默认 | ||
### 训练 | ||
直接执行如下命令即可进行模型训练: | ||
``` | ||
python train.py | ||
``` | ||
训练过程: | ||
```python | ||
Epoch: 9, Batch: [410/469], Train loss 0.186, Train acc: 0.938 | ||
Epoch: 9, Batch: [420/469], Train loss 0.150, Train acc: 0.938 | ||
Epoch: 9, Batch: [430/469], Train loss 0.269, Train acc: 0.941 | ||
Epoch: 9, Batch: [440/469], Train loss 0.197, Train acc: 0.925 | ||
Epoch: 9, Batch: [450/469], Train loss 0.245, Train acc: 0.917 | ||
Epoch: 9, Batch: [460/469], Train loss 0.272, Train acc: 0.902 | ||
Accuracy on test 0.886 | ||
``` | ||
|