노트/Python : 프로그래밍(69)
-
[자연어처리] 번역기 프로그램 만들기
데이터 www.manythings.org/anki/ Tab-delimited Bilingual Sentence Pairs from the Tatoeba Project (Good for Anki and Similar Flashcard Applications) Introducing Anki If you don't already use Anki, vist the website at http://ankisrs.net/ to download this free application for Macintosh, Windows or Linux. About These Files Any flashcard program that can import tab-delimited text files, such as Anki (fre..
2020.05.14 -
[자연어처리] 케라스로 단어사전 만들기
단어 토큰화 from keras.preprocessing.text import Tokenizer tok = Tokenizer() text = "Regret for wasted time is more wasted time" tok.fit_on_texts([text]) # 사전을 생성 #[text] : 단어 단위 토큰화 #text : 문자 단위 토큰화 print(tok.word_index) test = "Regret for wasted time is more wasted hour" seq = tok.texts_to_sequences([test]) # 사전에 test에 저장된 단어가 있는지 확인 from keras.preprocessing.sequence import pad_sequences # pad_seq..
2020.05.08 -
[신경망] LSTM을 이용한 "나비야" 작곡하기 코드
# (text) 텍스트를 읽어주는 라이브러리 from gtts import gTTS import numpy as np texte = "Hi, everybody, Playing with TF is fun" tts = gTTS(text=text , lang="en") tts.save("hi.mp3") textk = "안녕하세요. 여러분 텐서플로우 재미있어요" tts = gTTS(text=text , lang="ko") tts.save("hiko.mp3") ttsEn=gTTS(text=texte, lang="en") ttsKr=gTTS(text=textk, lang="ko") f = open("enkr.mp3","wb") ttsEn.write_to_fp(f) ttsEn.write_to_fp(f) ttsKr.w..
2020.05.08 -
[신경망] RNN을 이용한 주식가격 예측 알고리즘 코드
데이터 코드 import tensorflow as tf import numpy as np import matplotlib.pyplot as plt import pandas as pd import seaborn as sns def MinMaxScaler(data): denom=np.max(data,0)-np.min(data,0) nume=data-np.min(data,0) return nume/denom #정규화 path = "C:\\Users\\student\\Desktop\\DY\\★ 데이터\\105. deep-learning-dataset\\" xy=np.loadtxt(path+"data-02-stock_daily.csv", delimiter=",", skiprows=0+1+1) xy=xy[::-1]..
2020.05.07 -
[신경망] RNN을 이용한 단어 번역 알고리즘 코드
단어 정의 """ S : 인코딩 입력의 시작 E : 디코딩 출력의 끝 P : 현재 배치되는 데이터의 time step 크기보다 작은 경우 빈 시퀀스를 채우는 심볼 배치 데이터의 최대 크기 4 인경우, word = > ['w','o','r','d'] to => ['t','o','P','P'] """ char_arr=[c for c in "SEPabcdefghijklmnopqrstuvwxyz단어나무놀이소녀키스사랑"] num_dic={n:i for i, n in enumerate(char_arr)} dic_len=len(num_dic) seq_data=[['word','단어'], ['wood','나무'], ['game','놀이'], ['girl','소녀'], ['love','사랑'], ['kiss','키스']..
2020.05.01 -
[신경망] RNN을 이용한 다음 단어 완성 알고리즘 코드
개념 참고 포스팅 RNN과 LSTM 기본 구조 포스팅 코드 # wood -> 학습 -> 모델 # woo 입력 -----> 모델 -> d 예측 # wop 입력 -----> 모델 -> d 예측 (인공지능) # 알파벳 문자 리스트 대입 char_arr = [] for i in range(97,123): char_arr.append(chr(i)) char_arr num_dic = { char_arr[n] : n for n in range(26) } # 다른방법 num_dic = { n : i for i , n in enumerate(char_arr)} dic_len = len(num_dic) 학습 데이터 생성 seq_data =['word', 'wood', 'deep', 'dive', 'cold', 'cool'..
2020.05.01