Skip to content

Commit f7d8b89

Browse files
committed
Create Usage.md
1 parent 965fa2d commit f7d8b89

1 file changed

Lines changed: 142 additions & 0 deletions

File tree

‎Usage.md‎

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
# Usage
2+
3+
## Options
4+
5+
### Input and output options
6+
7+
```
8+
--train-file STR Training file. Default is `data/Train_sample.json`.
9+
--validation-file STR Validation file. Default is `data/Validation_sample.json`.
10+
--testing-file STR Testing file. Default is `data/Test_sample.json`.
11+
--word2vec-file STR Word2vec model file. Default is `data/word2vec_100.model`.
12+
```
13+
14+
### Model option
15+
16+
```
17+
--pad-seq-len INT Padding Sequence length of data. Depends on data.
18+
--embedding-type INT The embedding type. Default is 1.
19+
--embedding-dim INT Dim of character embedding. Default is 100.
20+
--filter-sizes LIST Filter sizes. Default is [3,4,5].
21+
--num-filters INT Number of filters per filter size. Default is 128.
22+
--pooling-size INT Pooling size. Default is 3.
23+
--lstm-dim INT Dim of LSTM neurons. Default is 256.
24+
--lstm-layers INT Number of LSTM layers. Defatul is 1.
25+
--attention-dim INT Dim of Attention neurons. Default is 200.
26+
--attention-hops-dim INT Dim of Attention hops. Default is 30.
27+
--fc-dim INT Dim of FC neurons. Default is 512.
28+
--dropout-rate FLOAT Dropout keep probability. Default is 0.5.
29+
--num-classes INT Total number of labels. Depends on data.
30+
--topK INT Number of top K prediction classes. Default is 5.
31+
--threshold FLOAT Threshold for prediction classes. Default is 0.5.
32+
```
33+
34+
### Training option
35+
36+
```
37+
--epochs INT Number of epochs. Default is 100.
38+
--batch-size INT Batch size. Default is 256.
39+
--learning-rate FLOAT Adam learning rate. Default is 0.001.
40+
--decay-rate FLOAT Rate of decay for learning rate. Default is 0.95.
41+
--decay-steps INT How many steps before decy lr. Default is 500.
42+
--evaluate-steps INT How many steps to evluate val set. Default is 500.
43+
--l2-lambda FLOAT L2 regularization lambda. Default is 0.0.
44+
--checkpoint-steps INT How many steps to save model. Default is 500.
45+
--num-checkpoints INT Number of checkpoints to store. Default is 500.
46+
```
47+
48+
## Training
49+
50+
The following commands train a model. (Use CNN for example)
51+
52+
```bash
53+
$ python3 train_cnn.py
54+
```
55+
56+
Training a model for a 200 epochs and set batch size as 128.
57+
58+
```bash
59+
$ python3 train_cnn.py --epochs 200 --batch-size 128
60+
```
61+
62+
In the beginning, you will see the program shows:
63+
64+
![](https://live.staticflickr.com/65535/49726025868_da2759aaea_o.png)
65+
66+
**You need to choose Training or Restore. (T for Training and R for Restore)**
67+
68+
After training, you will get the `/log` and `/run` folder.
69+
70+
- `/log` folder saves the log info file.
71+
- `/run` folder saves the checkpoints.
72+
73+
It should be like this:
74+
75+
```text
76+
.
77+
├── logs
78+
├── runs
79+
│   └── 1585814009 [a 10-digital format]
80+
│   ├── bestcheckpoints
81+
│   ├── checkpoints
82+
│   ├── embedding
83+
│   └── summaries
84+
├── test_cnn.py
85+
├── text_cnn.py
86+
└── train_cnn.py
87+
```
88+
89+
**The programs name and identify the model by using the asctime (It should be 10-digital number, like 1585814009).**
90+
91+
## Restore
92+
93+
When your model stops training for some reason and you want to restore training, you can:
94+
95+
In the beginning, you will see the program shows:
96+
97+
![](https://live.staticflickr.com/65535/49726620511_f2e3abdfac_o.png)
98+
99+
**And you need to input R for restore.**
100+
101+
Then you will be asked to give the model name (a 10-digital format, like 1585814009):
102+
103+
![](https://live.staticflickr.com/65535/49726066673_1732b92b96_o.png)
104+
105+
And the model will continue training from the last time.
106+
107+
## Test
108+
109+
The following commands test a model.
110+
111+
```bash
112+
$ python3 test_cnn.py
113+
```
114+
115+
Then you will be asked to give the model name (a 10-digital format, like 1585814009):
116+
117+
![](https://live.staticflickr.com/65535/49726643681_25f83b405e_o.png)
118+
119+
And you can choose to use the best model or the latest model **(B for Best, L for Latest)**:
120+
121+
![](https://live.staticflickr.com/65535/49726644721_b552318c16_o.png)
122+
123+
Finally, you can get the `predictions.json` file under the `/outputs` folder, it should be like:
124+
125+
```text
126+
.
127+
├── graph
128+
├── logs
129+
├── output
130+
│   └── 1585814009
131+
│   └── predictions.json
132+
├── runs
133+
│   └── 1585814009
134+
│   ├── bestcheckpoints
135+
│   ├── checkpoints
136+
│   ├── embedding
137+
│   └── summaries
138+
├── test_cnn.py
139+
├── text_cnn.py
140+
└── train_cnn.py
141+
```
142+

0 commit comments

Comments
 (0)