
376
3
부
애플리케이션
Epoch 1/10
145061/145061 [==============================] - 241s 2ms/step
- loss: 3.7840 - accuracy: 0.3894
...
Epoch 10/10
145061/145061 [==============================] - 244s 2ms/step
- loss: 1.8933 - accuracy: 0.5645
일단 이 모델이 학습되면 우리는 몇몇 문장을 생성해볼 수 있다. 이 함수에는 문맥 문장과 입력
문장이 필요하다. 우리는 시작하는 데 필요한 한 단어를 제공할 수 있다. 이 함수는
END
토큰이
생성되거나 최대 허용 길이에 도달할 때까지 입력 문장에 토큰을 추가한다.
def generate_sentence(context_sentence, input_sentence, max_len=100):
context_sentence = [t.lower() for t in nltk.tokenize.wordpunct_tokenize(context_
sentence)]
context_sentence = pad_sentence(context_sentence, max_len)
context_vector = sent2mat(context_sentence, glove)