cnn text classification pytorch
1.0.0
이것은 Pytorch의 문장 분류 논문을위한 Kim의 Convolutional Neural Networks의 구현입니다.
방금 두 개의 데이터 세트 인 MR과 SST를 시도했습니다.
| 데이터 세트 | 클래스 크기 | 최상의 결과 | 김의 논문 결과 |
|---|---|---|---|
| 씨 | 2 | 77.5%(CNN-Rand-Static) | 76.1%(CNN-Rand-Nostatic) |
| SST | 5 | 37.2%(CNN-Rand-Static) | 45.0%(CNN-Rand-Nostatic) |
SST를 위해 하이퍼 파라미터를 조정하지 않았습니다.
./main.py -h
또는
python3 main.py -h
당신은 얻을 것입니다 :
CNN text classificer
optional arguments:
-h, --help show this help message and exit
-batch-size N batch size for training [default: 50]
-lr LR initial learning rate [default: 0.01]
-epochs N number of epochs for train [default: 10]
-dropout the probability for dropout [default: 0.5]
-max_norm MAX_NORM l2 constraint of parameters
-cpu disable the gpu
-device DEVICE device to use for iterate data
-embed-dim EMBED_DIM
-static fix the embedding
-kernel-sizes KERNEL_SIZES
Comma-separated kernel size to use for convolution
-kernel-num KERNEL_NUM
number of each kind of kernel
-class-num CLASS_NUM number of class
-shuffle shuffle the data every epoch
-num-workers NUM_WORKERS
how many subprocesses to use for data loading
[default: 0]
-log-interval LOG_INTERVAL
how many batches to wait before logging training
status
-test-interval TEST_INTERVAL
how many epochs to wait before testing
-save-interval SAVE_INTERVAL
how many epochs to wait before saving
-predict PREDICT predict the sentence given
-snapshot SNAPSHOT filename of model snapshot [default: None]
-save-dir SAVE_DIR where to save the checkpoint
./main.py
당신은 얻을 것입니다 :
Batch[100] - loss: 0.655424 acc: 59.3750%
Evaluation - loss: 0.672396 acc: 57.6923%(615/1066)
테스트 세트를 구성 한 경우 다음과 같은 테스트를합니다.
/main.py -test -snapshot="./snapshot/2017-02-11_15-50-53/snapshot_steps1500.pt
스냅 샷 옵션은 모델로드의 위치를 의미합니다. 할당하지 않으면 모델이 처음부터 시작됩니다.
예제 1
./main.py -predict="Hello my dear , I love you so much ."
-snapshot="./snapshot/2017-02-11_15-50-53/snapshot_steps1500.pt"
당신은 얻을 것입니다 :
Loading model from [./snapshot/2017-02-11_15-50-53/snapshot_steps1500.pt]...
[Text] Hello my dear , I love you so much .
[Label] positive
예제 2
./main.py -predict="You just make me so sad and I have to leave you ."
-snapshot="./snapshot/2017-02-11_15-50-53/snapshot_steps1500.pt"
당신은 얻을 것입니다 :
Loading model from [./snapshot/2017-02-11_15-50-53/snapshot_steps1500.pt]...
[Text] You just make me so sad and I have to leave you .
[Label] negative
텍스트는 공간, 구두점에 의해서도 구분되어야하며, 텍스트는 최대 커널 크기보다 길어야합니다.