Text classification with CNN, RNN, RCNN model by character, word level
- 한글 문서에 대해 classifier를 만든 예
- Tensorflow(tensorflow-gpu==1.8.0)를 이용했으며, Convolutional layer, Recurrent layer를 이용
- 실 데이터를 사용(전에 공부용으로 수집한 데이터 인데, 문제될 경우 내리겠습니다.)
data link: https://drive.google.com/open?id=1vdvedBSAcVU8Dbjzuow6cL_9Tkc9zGVM -출처: W 영화 사이트
- data_preprocessing.py: 텍스트 기본 전처리 진행
- 특수문자 제거
- corpus의 문장 길이 10분위수 ~ 95분위수만 사용
- 2점 이하: 부정, 5점: 긍정으로 나누어 label 비율을 최대한 반반으로 설정
- data_load.py: 데이터 불러오기
- Jaso_mapping_utils.py: 텐서에서 자소를 onehot vector로 변환
- 자소 단위로 input을 받는 모형에 대해 적용
- make_VocabularyProcessor.py: 텐서에서 단어를 index로 변환
- 제공하는 VocabularyProcessor를 사용하여 객체 생성
- utils.py: layers, batch generate, tokenizer 등 사용할 함수 정의
character level CNN text classifier
- 자소 단위의 input을 받는 CNN text classifier
- 인터넷의 언어 파괴적 문서, 오타 등에 강건한 모형
- Text_CNN_config.py:
- model과 관련한 hyper-parameter 정의
- Text_CNN_model.py:
- model class
- Text_CNN_train.py:
- 모형을 학습하고, tensorboard로 summary를 확인 및 학습된 파라미터 저장
- Text_CNN_predict.py:
- 학습된 모형에 test data를 적용해 성능지표 산출
character level RNN text classifier
- 자소 단위의 input을 받는 RNN text classifier
- 불필요하게 sequence를 길게한 탓인지, 자소 단위의 RNN은 학습이 잘 되지 않음
- (이에 대한 원인을 알고 있으신 분이 있으시면 메일 부탁드립니다.)
- Text_RNN_config.py:
- model과 관련한 hyper-parameter 정의
- Text_RNN_model.py:
- model class
- Text_RNN_train.py:
- 모형을 학습하고, tensorboard로 summary를 확인 및 학습된 파라미터 저장
- Text_RNN_predict.py:
- 학습된 모형에 test data를 적용해 성능지표 산출
word level RNN text classifier
- 단어 단위의 input을 받는 RNN text classifier
- Text_RNN_word_config.py:
- model과 관련한 hyper-parameter 정의
- Text_RNN_word_model.py:
- model class
- Text_RNN_word_train.py:
- 모형을 학습하고, tensorboard로 summary를 확인 및 학습된 파라미터 저장
- Text_RNN_word_predict.py:
- 학습된 모형에 test data를 적용해 성능지표 산출
word level RNN text classifier with attention
- 단어 단위의 input을 받는 RNN text classifier + attention
- Text_RNN_word_attention_config.py:
- model과 관련한 hyper-parameter 정의
- Text_RNN_word_attention_model.py:
- model class
- Text_RNN_word_attention_train.py:
- 모형을 학습하고, tensorboard로 summary를 확인 및 학습된 파라미터 저장
- Text_RNN_word_attention_predict.py:
- 학습된 모형에 test data를 적용해 성능지표 산출
word level RCNN text classifier with attention
- 단어 단위의 input을 받는 CNN+RNN text classifier + attention
- Text_RCNN_word_attention_config.py:
- model과 관련한 hyper-parameter 정의
- Text_RCNN_word_attention_model.py:
- model class
- Text_RCNN_word_attention_train.py:
- 모형을 학습하고, tensorboard로 summary를 확인 및 학습된 파라미터 저장
- Text_RCNN_word_attention_predict.py:
- 학습된 모형에 test data를 적용해 성능지표 산출