skinOptions.hljs
[NLP Project] 성능 기록
·
Project/캡스톤디자인2
모델명: test_model.h5 파라미터 설정 test-train split : 8:2 Optimaizer: Adam Epoch = 3 batch_size=128 Learning_rate = 0.001 성능 loss: 0.1447 - accuracy: 0.7625 모델명: test_model2.h5 파라미터 설정 test-train split : 8:2 Optimaizer: Adam Epoch = 20 batch_size=128 Learning_rate = 0.005 성능 loss: 0.1796 - accuracy: 0.7463 학습로그 더보기 Epoch 1/20 2022-11-06 01:29:32.795455: I tensorflow/stream_executor/platform/default/dso_..
[NLP Project] 5. 정답 예측하기
·
Project/캡스톤디자인2
출력한 값을 토대로 정답을 예측하는 함수를 만들었다. 이번에는 모델을 학습 시키고 저장한 뒤 로드한 모델로 출력하는 함수까지 구현하였다. def model_predict(src_tokenizer,tar_tokenizer,model): # 예측 idx2word = src_tokenizer.index_word idx2ner = tar_tokenizer.index_word idx2ner[0] = 'PAD' i = 10 y_predicted = model.predict(np.array([X_test[i]])) y_predicted = np.argmax(y_predicted, axis = -1) # 가장 높은 확률을 추출 (예측값) true = np.argmax(y_test[i],-1) # 실제 값 print("..
[NLP Project] 4. LSTM 모델 구축
·
Project/캡스톤디자인2
모델 구축에는 keras 함수를 이용하였다. 그리고 옵티마이저는 Adam 모델의 구성은 다음과 같다. 1. 입력을 실수 벡터로 임베딩 2. 양방향 LSTM 구성 3. Dense Layer를 통한 각 태그에 속할 확률을 예측 TimeDistributed는 상위 layer의 출력이 step에 따라 여러개로 출력되어 이를 적절하게 분배해주는 역할을 한다. model.py from keras.models import Sequential from keras.layers import Dense, Embedding, LSTM, Bidirectional, TimeDistributed from keras.optimizers import Adam def modeling(vocab_size, max_len,tag_size)..
[NLP Project] 2. 토큰화 하기
·
Project/캡스톤디자인2
먼저 main.py를 생성하여 전체적인 실행을 관리할 파일을 만들었다. data_load.py import os # 파일 로드하고 텍스트파일 전처리하기 def file_load(file_path): tagged_sentences = [] sentences = [] with open(file_path,"r") as f: for line in f: if len(line) == 0 or line[0] == "\n": if len(sentences) > 0: tagged_sentences.append(sentences) sentences = [] splits = line.rstrip('\n').split('\t') if len(splits) == 3: sentences.append([splits[1],split..
[NLP Project] 1. 데이터 로드하고 전처리하기
·
Project/캡스톤디자인2
데이터를 로드하고 전처리해봅시다 사용한 데이터는 네이버 ner 데이터 셋을 이용하였습니다. 데이터셋 출처 -> https://github.com/naver/nlp-challenge GitHub - naver/nlp-challenge: NLP Shared tasks (NER, SRL) using NSML NLP Shared tasks (NER, SRL) using NSML. Contribute to naver/nlp-challenge development by creating an account on GitHub. github.com 해당 데이터셋을 텍스트파일로 바꾸어 사용하였습니다. 데이터는 이렇게 각 문장의 인덱스와 단어, 개체명 순서로 있습니다. 그럼 데이터를 사용하기 편하도록 전처리 해보겠습니다. ..