From d4ce992db21435ac51ba1af388030fdbb8ec8a03 Mon Sep 17 00:00:00 2001
From: HyeonhoonLee <68671051+HyeonhoonLee@users.noreply.github.com>
Date: Tue, 20 Oct 2020 13:57:40 +0900
Subject: [PATCH] init: Attention layer is added to previous LSTM model
---
models/Okt_LSTM/LSTM+Attention.ipynb | 3167 ++++++++++++++++++++++++++
1 file changed, 3167 insertions(+)
create mode 100644 models/Okt_LSTM/LSTM+Attention.ipynb
diff --git a/models/Okt_LSTM/LSTM+Attention.ipynb b/models/Okt_LSTM/LSTM+Attention.ipynb
new file mode 100644
index 0000000..375f25a
--- /dev/null
+++ b/models/Okt_LSTM/LSTM+Attention.ipynb
@@ -0,0 +1,3167 @@
+{
+ "nbformat": 4,
+ "nbformat_minor": 0,
+ "metadata": {
+ "kernelspec": {
+ "display_name": "Python 3",
+ "language": "python",
+ "name": "python3"
+ },
+ "language_info": {
+ "codemirror_mode": {
+ "name": "ipython",
+ "version": 3
+ },
+ "file_extension": ".py",
+ "mimetype": "text/x-python",
+ "name": "python",
+ "nbconvert_exporter": "python",
+ "pygments_lexer": "ipython3",
+ "version": "3.7.4"
+ },
+ "colab": {
+ "name": "LSTM",
+ "provenance": [],
+ "collapsed_sections": []
+ },
+ "accelerator": "GPU"
+ },
+ "cells": [
+ {
+ "cell_type": "code",
+ "metadata": {
+ "id": "sco7gWp7ej-9",
+ "outputId": "ce6a2b1f-86c9-44de-8cdd-952c4e95bd73",
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 34
+ }
+ },
+ "source": [
+ "from google.colab import drive\n",
+ "drive.mount('/content/drive')"
+ ],
+ "execution_count": 1,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "text": [
+ "Drive already mounted at /content/drive; to attempt to forcibly remount, call drive.mount(\"/content/drive\", force_remount=True).\n"
+ ],
+ "name": "stdout"
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "metadata": {
+ "id": "uzob-2SXZp4m",
+ "outputId": "db51f468-4e6c-4fc0-a768-4d5dc2980833",
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 419
+ }
+ },
+ "source": [
+ "import numpy as np \n",
+ "import pandas as pd\n",
+ "import tensorflow as tf\n",
+ "import tensorflow.keras as keras\n",
+ "from tensorflow.keras.preprocessing.text import Tokenizer\n",
+ "from tensorflow.keras.preprocessing.sequence import pad_sequences\n",
+ "\n",
+ "df = pd.read_csv('https://raw.githubusercontent.com/HyeonhoonLee/Infra_Meditact_Meditact/master/data/preprocessed_clean20571.csv')\n",
+ "df"
+ ],
+ "execution_count": 2,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/html": [
+ "
\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " nouns | \n",
+ " label | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " 0 | \n",
+ " 이어폰 음량 귀 | \n",
+ " 6 | \n",
+ "
\n",
+ " \n",
+ " 1 | \n",
+ " 독감 예방주사 | \n",
+ " 2 | \n",
+ "
\n",
+ " \n",
+ " 2 | \n",
+ " 목 음식물 계속 물감 | \n",
+ " 6 | \n",
+ "
\n",
+ " \n",
+ " 3 | \n",
+ " 케겔 운동 | \n",
+ " 10 | \n",
+ "
\n",
+ " \n",
+ " 4 | \n",
+ " 등 통증 문의 | \n",
+ " 11 | \n",
+ "
\n",
+ " \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ "
\n",
+ " \n",
+ " 20566 | \n",
+ " 허리 통증 다리 저림 | \n",
+ " 11 | \n",
+ "
\n",
+ " \n",
+ " 20567 | \n",
+ " 척추 분리 증 글 | \n",
+ " 11 | \n",
+ "
\n",
+ " \n",
+ " 20568 | \n",
+ " 뼈 통증 | \n",
+ " 17 | \n",
+ "
\n",
+ " \n",
+ " 20569 | \n",
+ " 무릎 연골 수술 운동 방법 | \n",
+ " 10 | \n",
+ "
\n",
+ " \n",
+ " 20570 | \n",
+ " 마지막 좀 감 전시 흉부 | \n",
+ " 5 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
20571 rows × 2 columns
\n",
+ "
"
+ ],
+ "text/plain": [
+ " nouns label\n",
+ "0 이어폰 음량 귀 6\n",
+ "1 독감 예방주사 2\n",
+ "2 목 음식물 계속 물감 6\n",
+ "3 케겔 운동 10\n",
+ "4 등 통증 문의 11\n",
+ "... ... ...\n",
+ "20566 허리 통증 다리 저림 11\n",
+ "20567 척추 분리 증 글 11\n",
+ "20568 뼈 통증 17\n",
+ "20569 무릎 연골 수술 운동 방법 10\n",
+ "20570 마지막 좀 감 전시 흉부 5\n",
+ "\n",
+ "[20571 rows x 2 columns]"
+ ]
+ },
+ "metadata": {
+ "tags": []
+ },
+ "execution_count": 2
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "metadata": {
+ "scrolled": true,
+ "id": "dX4lUamEZp4q",
+ "outputId": "d7b487d0-7dd2-41ff-b009-7810d93c9268",
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 419
+ }
+ },
+ "source": [
+ "df['nounlist'] = df['nouns'].str.split()\n",
+ "df.dropna(inplace=True)\n",
+ "df"
+ ],
+ "execution_count": 3,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " nouns | \n",
+ " label | \n",
+ " nounlist | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " 0 | \n",
+ " 이어폰 음량 귀 | \n",
+ " 6 | \n",
+ " [이어폰, 음량, 귀] | \n",
+ "
\n",
+ " \n",
+ " 1 | \n",
+ " 독감 예방주사 | \n",
+ " 2 | \n",
+ " [독감, 예방주사] | \n",
+ "
\n",
+ " \n",
+ " 2 | \n",
+ " 목 음식물 계속 물감 | \n",
+ " 6 | \n",
+ " [목, 음식물, 계속, 물감] | \n",
+ "
\n",
+ " \n",
+ " 3 | \n",
+ " 케겔 운동 | \n",
+ " 10 | \n",
+ " [케겔, 운동] | \n",
+ "
\n",
+ " \n",
+ " 4 | \n",
+ " 등 통증 문의 | \n",
+ " 11 | \n",
+ " [등, 통증, 문의] | \n",
+ "
\n",
+ " \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ "
\n",
+ " \n",
+ " 20566 | \n",
+ " 허리 통증 다리 저림 | \n",
+ " 11 | \n",
+ " [허리, 통증, 다리, 저림] | \n",
+ "
\n",
+ " \n",
+ " 20567 | \n",
+ " 척추 분리 증 글 | \n",
+ " 11 | \n",
+ " [척추, 분리, 증, 글] | \n",
+ "
\n",
+ " \n",
+ " 20568 | \n",
+ " 뼈 통증 | \n",
+ " 17 | \n",
+ " [뼈, 통증] | \n",
+ "
\n",
+ " \n",
+ " 20569 | \n",
+ " 무릎 연골 수술 운동 방법 | \n",
+ " 10 | \n",
+ " [무릎, 연골, 수술, 운동, 방법] | \n",
+ "
\n",
+ " \n",
+ " 20570 | \n",
+ " 마지막 좀 감 전시 흉부 | \n",
+ " 5 | \n",
+ " [마지막, 좀, 감, 전시, 흉부] | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
20420 rows × 3 columns
\n",
+ "
"
+ ],
+ "text/plain": [
+ " nouns label nounlist\n",
+ "0 이어폰 음량 귀 6 [이어폰, 음량, 귀]\n",
+ "1 독감 예방주사 2 [독감, 예방주사]\n",
+ "2 목 음식물 계속 물감 6 [목, 음식물, 계속, 물감]\n",
+ "3 케겔 운동 10 [케겔, 운동]\n",
+ "4 등 통증 문의 11 [등, 통증, 문의]\n",
+ "... ... ... ...\n",
+ "20566 허리 통증 다리 저림 11 [허리, 통증, 다리, 저림]\n",
+ "20567 척추 분리 증 글 11 [척추, 분리, 증, 글]\n",
+ "20568 뼈 통증 17 [뼈, 통증]\n",
+ "20569 무릎 연골 수술 운동 방법 10 [무릎, 연골, 수술, 운동, 방법]\n",
+ "20570 마지막 좀 감 전시 흉부 5 [마지막, 좀, 감, 전시, 흉부]\n",
+ "\n",
+ "[20420 rows x 3 columns]"
+ ]
+ },
+ "metadata": {
+ "tags": []
+ },
+ "execution_count": 3
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "metadata": {
+ "scrolled": true,
+ "id": "sBokAcMCZp4t",
+ "outputId": "8e736413-f4bd-46e5-c2b8-d5b9e9acbba8",
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 34
+ }
+ },
+ "source": [
+ "from sklearn.model_selection import train_test_split\n",
+ "x_train_, x_test_, y_train, y_test = train_test_split(\n",
+ " df['nounlist'], df['label'], \n",
+ " test_size=0.2, random_state=1234, \n",
+ " stratify=df['label']\n",
+ " )\n",
+ "\n",
+ "x_train_.shape, x_test_.shape, y_train.shape, y_test.shape"
+ ],
+ "execution_count": 4,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "((16336,), (4084,), (16336,), (4084,))"
+ ]
+ },
+ "metadata": {
+ "tags": []
+ },
+ "execution_count": 4
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "metadata": {
+ "scrolled": true,
+ "id": "AYE2TMOgZp4x",
+ "outputId": "312d4286-4f2e-468d-e554-7e97b63f6d41",
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 204
+ }
+ },
+ "source": [
+ "x_train_.head(10)"
+ ],
+ "execution_count": 5,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "2760 [안압]\n",
+ "12483 [무대, 공포]\n",
+ "6704 [뇌출혈, 인지, 기능, 저하]\n",
+ "5829 [요산, 수치]\n",
+ "4666 [대변, 볼때, 피, 가득]\n",
+ "17675 [냄새, 못, 얼굴, 경련, 증상, 검사]\n",
+ "20076 [추간판탈출증, 관]\n",
+ "4211 [대상포진]\n",
+ "9775 [중학생, 식탐, 심해]\n",
+ "147 [장, 위장, 것]\n",
+ "Name: nounlist, dtype: object"
+ ]
+ },
+ "metadata": {
+ "tags": []
+ },
+ "execution_count": 5
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "metadata": {
+ "id": "AQEbT1e2Zp40",
+ "outputId": "af855b7e-acf9-4038-951c-e50a277c6d29",
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 1000
+ }
+ },
+ "source": [
+ "vocab_size = 8000\n",
+ "t = Tokenizer(num_words=vocab_size)\n",
+ "t.fit_on_texts(df['nounlist'])\n",
+ "\n",
+ "t.word_index"
+ ],
+ "execution_count": 6,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "{'통증': 1,\n",
+ " '증상': 2,\n",
+ " '무릎': 3,\n",
+ " '허리': 4,\n",
+ " '약': 5,\n",
+ " '목': 6,\n",
+ " '운동': 7,\n",
+ " '치료': 8,\n",
+ " '복용': 9,\n",
+ " '수술': 10,\n",
+ " '잠': 11,\n",
+ " '왼쪽': 12,\n",
+ " '우울증': 13,\n",
+ " '머리': 14,\n",
+ " '디스크': 15,\n",
+ " '다리': 16,\n",
+ " '어깨': 17,\n",
+ " '가슴': 18,\n",
+ " '스트레스': 19,\n",
+ " '두통': 20,\n",
+ " '검사': 21,\n",
+ " '오른쪽': 22,\n",
+ " '질문': 23,\n",
+ " '증': 24,\n",
+ " '골절': 25,\n",
+ " '근육': 26,\n",
+ " '수': 27,\n",
+ " '방법': 28,\n",
+ " '심장': 29,\n",
+ " '발목': 30,\n",
+ " '관절': 31,\n",
+ " '부분': 32,\n",
+ " '인대': 33,\n",
+ " '몸': 34,\n",
+ " '등': 35,\n",
+ " '정신과': 36,\n",
+ " '신경': 37,\n",
+ " '불안': 38,\n",
+ " '소리': 39,\n",
+ " '뼈': 40,\n",
+ " '병원': 41,\n",
+ " '손가락': 42,\n",
+ " '파열': 43,\n",
+ " '불면증': 44,\n",
+ " '수면': 45,\n",
+ " '척추': 46,\n",
+ " '문의': 47,\n",
+ " '이상': 48,\n",
+ " '공황장애': 49,\n",
+ " '상담': 50,\n",
+ " '주사': 51,\n",
+ " '힘': 52,\n",
+ " '요': 53,\n",
+ " '발': 54,\n",
+ " '술': 55,\n",
+ " '손': 56,\n",
+ " '걸': 57,\n",
+ " '저림': 58,\n",
+ " '염': 59,\n",
+ " '연골': 60,\n",
+ " '사람': 61,\n",
+ " '장애': 62,\n",
+ " '배': 63,\n",
+ " '강박증': 64,\n",
+ " '팔': 65,\n",
+ " '눈': 66,\n",
+ " '수치': 67,\n",
+ " '증후군': 68,\n",
+ " '부작용': 69,\n",
+ " '건강': 70,\n",
+ " '생각': 71,\n",
+ " '진단': 72,\n",
+ " '위': 73,\n",
+ " '종아리': 74,\n",
+ " '이유': 75,\n",
+ " '감': 76,\n",
+ " '번': 77,\n",
+ " '걱정': 78,\n",
+ " '호흡': 79,\n",
+ " '과': 80,\n",
+ " '살': 81,\n",
+ " '골반': 82,\n",
+ " '밤': 83,\n",
+ " '정신': 84,\n",
+ " '임신': 85,\n",
+ " '아침': 86,\n",
+ " '손목': 87,\n",
+ " '생리': 88,\n",
+ " '중': 89,\n",
+ " '대한': 90,\n",
+ " '허벅지': 91,\n",
+ " '숨': 92,\n",
+ " '개월': 93,\n",
+ " '조금': 94,\n",
+ " '아이': 95,\n",
+ " '약물': 96,\n",
+ " '증세': 97,\n",
+ " '재활': 98,\n",
+ " '음식': 99,\n",
+ " '상태': 100,\n",
+ " '환자': 101,\n",
+ " '관절염': 102,\n",
+ " '건가': 103,\n",
+ " '팔꿈치': 104,\n",
+ " '알': 105,\n",
+ " '하루': 106,\n",
+ " '재': 107,\n",
+ " '피': 108,\n",
+ " '코': 109,\n",
+ " '부위': 110,\n",
+ " '변': 111,\n",
+ " '엉덩이': 112,\n",
+ " '더': 113,\n",
+ " '염증': 114,\n",
+ " '기억': 115,\n",
+ " '당뇨': 116,\n",
+ " '시간': 117,\n",
+ " '식도염': 118,\n",
+ " '발바닥': 119,\n",
+ " '발가락': 120,\n",
+ " '자고': 121,\n",
+ " '도움': 122,\n",
+ " '일': 123,\n",
+ " '마비': 124,\n",
+ " '처방': 125,\n",
+ " '내시경': 126,\n",
+ " '가능성': 127,\n",
+ " '원인': 128,\n",
+ " '현상': 129,\n",
+ " '류마티스': 130,\n",
+ " '역류성': 131,\n",
+ " '불안장애': 132,\n",
+ " '손상': 133,\n",
+ " '추가': 134,\n",
+ " '관': 135,\n",
+ " '혈압': 136,\n",
+ " '피부': 137,\n",
+ " '형': 138,\n",
+ " '질환': 139,\n",
+ " '조울증': 140,\n",
+ " '법': 141,\n",
+ " '갈비뼈': 142,\n",
+ " '근육통': 143,\n",
+ " '뇌': 144,\n",
+ " '꿈': 145,\n",
+ " '심해': 146,\n",
+ " '효과': 147,\n",
+ " '비': 148,\n",
+ " '진료': 149,\n",
+ " '못': 150,\n",
+ " '개': 151,\n",
+ " '안쪽': 152,\n",
+ " '병': 153,\n",
+ " '승': 154,\n",
+ " '비타민': 155,\n",
+ " '어지럼증': 156,\n",
+ " '얼굴': 157,\n",
+ " '정': 158,\n",
+ " '치매': 159,\n",
+ " '양쪽': 160,\n",
+ " '데': 161,\n",
+ " '십자': 162,\n",
+ " '해도': 163,\n",
+ " '매일': 164,\n",
+ " '염려': 165,\n",
+ " '양제': 166,\n",
+ " '약간': 167,\n",
+ " '모근': 168,\n",
+ " '자세': 169,\n",
+ " '소화': 170,\n",
+ " '결과': 171,\n",
+ " '혈당': 172,\n",
+ " '간염': 173,\n",
+ " '긴장': 174,\n",
+ " '뇌경색': 175,\n",
+ " '변비': 176,\n",
+ " '관리': 177,\n",
+ " '한번': 178,\n",
+ " '감각': 179,\n",
+ " '피임': 180,\n",
+ " '정상': 181,\n",
+ " '관계': 182,\n",
+ " '한쪽': 183,\n",
+ " '골': 184,\n",
+ " '피로': 185,\n",
+ " '시작': 186,\n",
+ " '항우울제': 187,\n",
+ " '강박': 188,\n",
+ " '남자': 189,\n",
+ " '명치': 190,\n",
+ " '자도': 191,\n",
+ " '주': 192,\n",
+ " '대하': 193,\n",
+ " '걷기': 194,\n",
+ " '어지러움': 195,\n",
+ " '초기': 196,\n",
+ " '소변': 197,\n",
+ " '교정': 198,\n",
+ " '기분': 199,\n",
+ " '밑': 200,\n",
+ " '저하': 201,\n",
+ " '입': 202,\n",
+ " '설사': 203,\n",
+ " '무기': 204,\n",
+ " '대장': 205,\n",
+ " '저리': 206,\n",
+ " '경추': 207,\n",
+ " '새벽': 208,\n",
+ " '내': 209,\n",
+ " '팔이': 210,\n",
+ " '해': 211,\n",
+ " '기침': 212,\n",
+ " '통': 213,\n",
+ " '스트레칭': 214,\n",
+ " '우측': 215,\n",
+ " '제거': 216,\n",
+ " '기능': 217,\n",
+ " '섭취': 218,\n",
+ " '집중': 219,\n",
+ " '속': 220,\n",
+ " '후유증': 221,\n",
+ " '느낌': 222,\n",
+ " '교통사고': 223,\n",
+ " '다이어트': 224,\n",
+ " '평소': 225,\n",
+ " '생활': 226,\n",
+ " '심박수': 227,\n",
+ " '듭니': 228,\n",
+ " '앞': 229,\n",
+ " '경련': 230,\n",
+ " '시술': 231,\n",
+ " '물': 232,\n",
+ " '수면제': 233,\n",
+ " '감정': 234,\n",
+ " '키': 235,\n",
+ " '날': 236,\n",
+ " '전방': 237,\n",
+ " '인지': 238,\n",
+ " '스테로이드': 239,\n",
+ " '재발': 240,\n",
+ " '왜': 241,\n",
+ " '가래': 242,\n",
+ " '우울': 243,\n",
+ " '습관': 244,\n",
+ " '고혈압': 245,\n",
+ " '족저근막염': 246,\n",
+ " '회전': 247,\n",
+ " '아래': 248,\n",
+ " '가야': 249,\n",
+ " '위염': 250,\n",
+ " '여자': 251,\n",
+ " '어머니': 252,\n",
+ " '영향': 253,\n",
+ " '물감': 254,\n",
+ " '조현병': 255,\n",
+ " '사진': 256,\n",
+ " '감기': 257,\n",
+ " '편두통': 258,\n",
+ " '아기': 259,\n",
+ " '꼭': 260,\n",
+ " '열': 261,\n",
+ " '장염': 262,\n",
+ " '현재': 263,\n",
+ " '성인': 264,\n",
+ " '사이': 265,\n",
+ " '여성': 266,\n",
+ " '퇴': 267,\n",
+ " '행성': 268,\n",
+ " '기도': 269,\n",
+ " '여부': 270,\n",
+ " '갑상선': 271,\n",
+ " '듯': 272,\n",
+ " '심리': 273,\n",
+ " '간': 274,\n",
+ " '감염': 275,\n",
+ " '혈관': 276,\n",
+ " '부정맥': 277,\n",
+ " '곤란': 278,\n",
+ " '점': 279,\n",
+ " '공포증': 280,\n",
+ " '게': 281,\n",
+ " '반복': 282,\n",
+ " '만성': 283,\n",
+ " '혀': 284,\n",
+ " '수도': 285,\n",
+ " '바로': 286,\n",
+ " '저녁': 287,\n",
+ " '기간': 288,\n",
+ " '온몸': 289,\n",
+ " '자': 290,\n",
+ " '마디': 291,\n",
+ " '자살': 292,\n",
+ " '협착증': 293,\n",
+ " '척추측만증': 294,\n",
+ " '귀': 295,\n",
+ " '물이': 296,\n",
+ " '손발': 297,\n",
+ " '초음파': 298,\n",
+ " '코로나': 299,\n",
+ " '부근': 300,\n",
+ " '발생': 301,\n",
+ " '간질': 302,\n",
+ " '수면장애': 303,\n",
+ " '계속': 304,\n",
+ " '체중': 305,\n",
+ " '증가': 306,\n",
+ " '완치': 307,\n",
+ " '고생': 308,\n",
+ " '쥐': 309,\n",
+ " '다른': 310,\n",
+ " '반월': 311,\n",
+ " '항문': 312,\n",
+ " '구토': 313,\n",
+ " '마음': 314,\n",
+ " '곳': 315,\n",
+ " '침': 316,\n",
+ " '공복': 317,\n",
+ " '뇌졸중': 318,\n",
+ " '복통': 319,\n",
+ " '복부': 320,\n",
+ " '정말': 321,\n",
+ " '외상': 322,\n",
+ " '깁스': 323,\n",
+ " '항생제': 324,\n",
+ " '아버지': 325,\n",
+ " '밥': 326,\n",
+ " '장기': 327,\n",
+ " '편': 328,\n",
+ " '엄마': 329,\n",
+ " '토': 330,\n",
+ " '입술': 331,\n",
+ " '턱': 332,\n",
+ " '일자': 333,\n",
+ " '동안': 334,\n",
+ " '혹': 335,\n",
+ " '전체': 336,\n",
+ " '염좌': 337,\n",
+ " '옆': 338,\n",
+ " '불량': 339,\n",
+ " '적': 340,\n",
+ " '압박': 341,\n",
+ " '좌측': 342,\n",
+ " '엄지손가락': 343,\n",
+ " '꼬리뼈': 344,\n",
+ " '후두': 345,\n",
+ " '살이': 346,\n",
+ " '위쪽': 347,\n",
+ " '성격': 348,\n",
+ " '행동': 349,\n",
+ " '계단': 350,\n",
+ " '사회': 351,\n",
+ " '독감': 352,\n",
+ " '예방접종': 353,\n",
+ " '숨쉬기': 354,\n",
+ " '뒤쪽': 355,\n",
+ " '언제': 356,\n",
+ " '가요': 357,\n",
+ " '땀': 358,\n",
+ " '팔다리': 359,\n",
+ " '집': 360,\n",
+ " '힘줄': 361,\n",
+ " '기면증': 362,\n",
+ " '옆구리': 363,\n",
+ " '폐렴': 364,\n",
+ " '냄새': 365,\n",
+ " '맥박': 366,\n",
+ " '해결': 367,\n",
+ " '고': 368,\n",
+ " '요새': 369,\n",
+ " '얼마': 370,\n",
+ " '요추': 371,\n",
+ " '좀': 372,\n",
+ " '무릎관절': 373,\n",
+ " '혈액': 374,\n",
+ " '사용': 375,\n",
+ " '연관': 376,\n",
+ " '아픔': 377,\n",
+ " '주변': 378,\n",
+ " '나이': 379,\n",
+ " '뇌출혈': 380,\n",
+ " '발등': 381,\n",
+ " '종일': 382,\n",
+ " '통풍': 383,\n",
+ " '강직': 384,\n",
+ " '음주': 385,\n",
+ " '편도염': 386,\n",
+ " '거북목': 387,\n",
+ " '쇄골': 388,\n",
+ " '전': 389,\n",
+ " '폐': 390,\n",
+ " '멍': 391,\n",
+ " '판': 392,\n",
+ " '약과': 393,\n",
+ " '상처': 394,\n",
+ " '가지': 395,\n",
+ " '탈모': 396,\n",
+ " '근막': 397,\n",
+ " '남성': 398,\n",
+ " '달리기': 399,\n",
+ " '정신병': 400,\n",
+ " '사고': 401,\n",
+ " '핀': 402,\n",
+ " '무릅': 403,\n",
+ " '답변': 404,\n",
+ " '때': 405,\n",
+ " '오메가': 406,\n",
+ " '체': 407,\n",
+ " '예전': 408,\n",
+ " '식사': 409,\n",
+ " '부터': 410,\n",
+ " '작년': 411,\n",
+ " '부어': 412,\n",
+ " '중간': 413,\n",
+ " '정강이': 414,\n",
+ " '입원': 415,\n",
+ " '변화': 416,\n",
+ " '저혈압': 417,\n",
+ " '고지혈증': 418,\n",
+ " '문제': 419,\n",
+ " '의식': 420,\n",
+ " '정신분열증': 421,\n",
+ " '아킬레스건': 422,\n",
+ " '대변': 423,\n",
+ " '미열': 424,\n",
+ " '위장': 425,\n",
+ " '누우': 426,\n",
+ " '임파선': 427,\n",
+ " '친구': 428,\n",
+ " '간수치': 429,\n",
+ " '또': 430,\n",
+ " '안면': 431,\n",
+ " '찌릿': 432,\n",
+ " '조절': 433,\n",
+ " '일주일': 434,\n",
+ " '정형외과': 435,\n",
+ " '공부': 436,\n",
+ " '충격': 437,\n",
+ " '보톡스': 438,\n",
+ " '항': 439,\n",
+ " '움': 440,\n",
+ " '질병': 441,\n",
+ " '건': 442,\n",
+ " '판정': 443,\n",
+ " '조언': 444,\n",
+ " '정도': 445,\n",
+ " '것': 446,\n",
+ " '몸살': 447,\n",
+ " '엑스레이': 448,\n",
+ " '예방': 449,\n",
+ " '흉부': 450,\n",
+ " '무리': 451,\n",
+ " '콜레스테롤': 452,\n",
+ " '근력': 453,\n",
+ " '발기부전': 454,\n",
+ " '나': 455,\n",
+ " '인공': 456,\n",
+ " '엄지': 457,\n",
+ " '날개': 458,\n",
+ " '신체': 459,\n",
+ " '마취': 460,\n",
+ " '자전거': 461,\n",
+ " '내과': 462,\n",
+ " '질': 463,\n",
+ " '기운': 464,\n",
+ " '성형': 465,\n",
+ " '혈변': 466,\n",
+ " '개선': 467,\n",
+ " '확률': 468,\n",
+ " '년': 469,\n",
+ " '혈': 470,\n",
+ " '추간판탈출증': 471,\n",
+ " '진통제': 472,\n",
+ " '부족': 473,\n",
+ " '얼마나': 474,\n",
+ " '성관계': 475,\n",
+ " '분리': 476,\n",
+ " '끝': 477,\n",
+ " '체온': 478,\n",
+ " '화가': 479,\n",
+ " '제일': 480,\n",
+ " '저희': 481,\n",
+ " '눈물': 482,\n",
+ " '니': 483,\n",
+ " '만': 484,\n",
+ " '새끼': 485,\n",
+ " '폭': 486,\n",
+ " '물리치료': 487,\n",
+ " '불편': 488,\n",
+ " '가스': 489,\n",
+ " '바이러스': 490,\n",
+ " '등쪽': 491,\n",
+ " '원래': 492,\n",
+ " '남편': 493,\n",
+ " '의학과': 494,\n",
+ " '인후': 495,\n",
+ " '감소': 496,\n",
+ " '확인': 497,\n",
+ " '위해': 498,\n",
+ " '담': 499,\n",
+ " '놀': 500,\n",
+ " '출혈': 501,\n",
+ " '휘': 502,\n",
+ " '심': 503,\n",
+ " '발작': 504,\n",
+ " '완화': 505,\n",
+ " '충': 506,\n",
+ " '환청': 507,\n",
+ " '강화': 508,\n",
+ " '정신건강': 509,\n",
+ " '차이': 510,\n",
+ " '자기': 511,\n",
+ " '급성': 512,\n",
+ " '중단': 513,\n",
+ " '유산균': 514,\n",
+ " '절제': 515,\n",
+ " '특정': 516,\n",
+ " '가나': 517,\n",
+ " '몸무게': 518,\n",
+ " '줄': 519,\n",
+ " '여드름': 520,\n",
+ " '폭식증': 521,\n",
+ " '크게': 522,\n",
+ " '점점': 523,\n",
+ " '겨드랑이': 524,\n",
+ " '식욕': 525,\n",
+ " '뇌졸증': 526,\n",
+ " '치료법': 527,\n",
+ " '혼자': 528,\n",
+ " '음식물': 529,\n",
+ " '손톱': 530,\n",
+ " '건강검진': 531,\n",
+ " '지방': 532,\n",
+ " '접종': 533,\n",
+ " '성분': 534,\n",
+ " '화': 535,\n",
+ " '이나': 536,\n",
+ " '거림': 537,\n",
+ " '낮': 538,\n",
+ " '함': 539,\n",
+ " '시험': 540,\n",
+ " '자위': 541,\n",
+ " '하체': 542,\n",
+ " '치가': 543,\n",
+ " '에이즈': 544,\n",
+ " '졸음': 545,\n",
+ " '수면시간': 546,\n",
+ " '불면': 547,\n",
+ " '체력': 548,\n",
+ " '자궁': 549,\n",
+ " '마그네슘': 550,\n",
+ " '주기': 551,\n",
+ " '상황': 552,\n",
+ " '주위': 553,\n",
+ " '차': 554,\n",
+ " '동반': 555,\n",
+ " '바닥': 556,\n",
+ " '새끼손가락': 557,\n",
+ " '자신': 558,\n",
+ " '판독': 559,\n",
+ " '잠도': 560,\n",
+ " '붓기': 561,\n",
+ " '신경안정제': 562,\n",
+ " '공포': 563,\n",
+ " '늘': 564,\n",
+ " '섬유': 565,\n",
+ " '전도': 566,\n",
+ " '자궁경부암': 567,\n",
+ " '출산': 568,\n",
+ " '생기': 569,\n",
+ " '식후': 570,\n",
+ " '배꼽': 571,\n",
+ " '물질': 572,\n",
+ " '여': 573,\n",
+ " '갑자기': 574,\n",
+ " '장': 575,\n",
+ " '촬영': 576,\n",
+ " '세포': 577,\n",
+ " '방금': 578,\n",
+ " '기립': 579,\n",
+ " '비염': 580,\n",
+ " '박동': 581,\n",
+ " '성적': 582,\n",
+ " '입냄새': 583,\n",
+ " '아주': 584,\n",
+ " '칼슘': 585,\n",
+ " '가운데': 586,\n",
+ " '쉬': 587,\n",
+ " '소견': 588,\n",
+ " '일상생활': 589,\n",
+ " '부': 590,\n",
+ " '중독': 591,\n",
+ " '보': 592,\n",
+ " '상상': 593,\n",
+ " '집착': 594,\n",
+ " '극복': 595,\n",
+ " '아들': 596,\n",
+ " '건망증': 597,\n",
+ " '추간판': 598,\n",
+ " '편도': 599,\n",
+ " '식품': 600,\n",
+ " '안정': 601,\n",
+ " '과민성': 602,\n",
+ " '흉통': 603,\n",
+ " '정수리': 604,\n",
+ " '저': 605,\n",
+ " '의': 606,\n",
+ " '위산': 607,\n",
+ " '사타구니': 608,\n",
+ " '바늘': 609,\n",
+ " '가족': 610,\n",
+ " '헤르페스': 611,\n",
+ " '숙면': 612,\n",
+ " '상': 613,\n",
+ " '아래쪽': 614,\n",
+ " '알콜': 615,\n",
+ " '앞쪽': 616,\n",
+ " '순간': 617,\n",
+ " '탈출': 618,\n",
+ " '남': 619,\n",
+ " '대칭': 620,\n",
+ " '슬': 621,\n",
+ " '불안감': 622,\n",
+ " '공황': 623,\n",
+ " '엄지발가락': 624,\n",
+ " '틱장애': 625,\n",
+ " '해소': 626,\n",
+ " '복': 627,\n",
+ " '흡연': 628,\n",
+ " '캡슐': 629,\n",
+ " '수가': 630,\n",
+ " '트림': 631,\n",
+ " '부비동염': 632,\n",
+ " '첨부': 633,\n",
+ " '종': 634,\n",
+ " '복합': 635,\n",
+ " '지속': 636,\n",
+ " '식도': 637,\n",
+ " '이명': 638,\n",
+ " '전신': 639,\n",
+ " '트': 640,\n",
+ " '호르몬': 641,\n",
+ " '활동': 642,\n",
+ " '볼': 643,\n",
+ " '알레르기': 644,\n",
+ " '처럼': 645,\n",
+ " '호전': 646,\n",
+ " '학교': 647,\n",
+ " '고통': 648,\n",
+ " '돌기': 649,\n",
+ " '전기': 650,\n",
+ " '알프': 651,\n",
+ " '깨': 652,\n",
+ " '거나': 653,\n",
+ " '제': 654,\n",
+ " '유전': 655,\n",
+ " '고개': 656,\n",
+ " '방광': 657,\n",
+ " '부종': 658,\n",
+ " '루게릭': 659,\n",
+ " '유도': 660,\n",
+ " '의욕': 661,\n",
+ " '화증': 662,\n",
+ " '잠꼬대': 663,\n",
+ " '망상': 664,\n",
+ " '짜증': 665,\n",
+ " '오른손': 666,\n",
+ " '탈구': 667,\n",
+ " '사후': 668,\n",
+ " '신장': 669,\n",
+ " '빈혈': 670,\n",
+ " '타이레놀': 671,\n",
+ " '천식': 672,\n",
+ " '일전': 673,\n",
+ " '흡입': 674,\n",
+ " '요즘': 675,\n",
+ " '외': 676,\n",
+ " '두드러기': 677,\n",
+ " '골다공증': 678,\n",
+ " '입안': 679,\n",
+ " '가능': 680,\n",
+ " '스쿼트': 681,\n",
+ " '불': 682,\n",
+ " '손바닥': 683,\n",
+ " '벌레': 684,\n",
+ " '동시': 685,\n",
+ " '한의원': 686,\n",
+ " '상승': 687,\n",
+ " '이제': 688,\n",
+ " '프로': 689,\n",
+ " '경직': 690,\n",
+ " '파이': 691,\n",
+ " '아빠': 692,\n",
+ " '의처증': 693,\n",
+ " '고정': 694,\n",
+ " '복숭아': 695,\n",
+ " '자인': 696,\n",
+ " '용법': 697,\n",
+ " '중앙': 698,\n",
+ " '종합': 699,\n",
+ " '조증': 700,\n",
+ " '면': 701,\n",
+ " '도중': 702,\n",
+ " '병명': 703,\n",
+ " '균': 704,\n",
+ " '곤': 705,\n",
+ " '결절': 706,\n",
+ " '가루': 707,\n",
+ " '갈색': 708,\n",
+ " '하나': 709,\n",
+ " '종류': 710,\n",
+ " '자꾸': 711,\n",
+ " '시기': 712,\n",
+ " '현기증': 713,\n",
+ " '보고': 714,\n",
+ " '직장': 715,\n",
+ " '갱년기': 716,\n",
+ " '협심증': 717,\n",
+ " '하나요': 718,\n",
+ " '뒤꿈치': 719,\n",
+ " '대상포진': 720,\n",
+ " '흉추': 721,\n",
+ " '지능': 722,\n",
+ " '여러가지': 723,\n",
+ " '의자': 724,\n",
+ " '봉합': 725,\n",
+ " '금': 726,\n",
+ " '좌우': 727,\n",
+ " '피해망상': 728,\n",
+ " '자낙스': 729,\n",
+ " '대퇴골': 730,\n",
+ " '재건': 731,\n",
+ " '슬개골': 732,\n",
+ " '이드': 733,\n",
+ " '유지': 734,\n",
+ " '짐': 735,\n",
+ " '선생님': 736,\n",
+ " '대처': 737,\n",
+ " '쯤': 738,\n",
+ " '올해': 739,\n",
+ " '차고': 740,\n",
+ " '온': 741,\n",
+ " '미세': 742,\n",
+ " '성기': 743,\n",
+ " '덜': 744,\n",
+ " '답답': 745,\n",
+ " '습': 746,\n",
+ " '점액': 747,\n",
+ " '평상시': 748,\n",
+ " '다발': 749,\n",
+ " '멍울': 750,\n",
+ " '종종': 751,\n",
+ " '다시': 752,\n",
+ " '지끈': 753,\n",
+ " '발뒤꿈치': 754,\n",
+ " '음성': 755,\n",
+ " '연고': 756,\n",
+ " '부정': 757,\n",
+ " '급': 758,\n",
+ " '무기력증': 759,\n",
+ " '직업': 760,\n",
+ " '실감': 761,\n",
+ " '견갑골': 762,\n",
+ " '트라우마': 763,\n",
+ " '뒷쪽': 764,\n",
+ " '접': 765,\n",
+ " '골프': 766,\n",
+ " '의존': 767,\n",
+ " '감퇴': 768,\n",
+ " '족': 769,\n",
+ " '시도': 770,\n",
+ " '골연화증': 771,\n",
+ " '건염': 772,\n",
+ " '장경': 773,\n",
+ " '중족골': 774,\n",
+ " '예방주사': 775,\n",
+ " '대장암': 776,\n",
+ " '등산': 777,\n",
+ " '커피': 778,\n",
+ " '액': 779,\n",
+ " '목구멍': 780,\n",
+ " '알러지': 781,\n",
+ " '어디': 782,\n",
+ " '암': 783,\n",
+ " '감사': 784,\n",
+ " '중이': 785,\n",
+ " '위증': 786,\n",
+ " '요법': 787,\n",
+ " '낭종': 788,\n",
+ " '애': 789,\n",
+ " '후': 790,\n",
+ " '자연': 791,\n",
+ " '식단': 792,\n",
+ " '풀': 793,\n",
+ " '발톱': 794,\n",
+ " '화장실': 795,\n",
+ " '보통': 796,\n",
+ " '구내염': 797,\n",
+ " '순환': 798,\n",
+ " '소아': 799,\n",
+ " '반응': 800,\n",
+ " '일어나서': 801,\n",
+ " '유발': 802,\n",
+ " '성': 803,\n",
+ " '화끈': 804,\n",
+ " '외과': 805,\n",
+ " '자주': 806,\n",
+ " '땐': 807,\n",
+ " '바깥쪽': 808,\n",
+ " '괴사': 809,\n",
+ " '달전': 810,\n",
+ " '주차': 811,\n",
+ " '발기': 812,\n",
+ " '수영': 813,\n",
+ " '다한증': 814,\n",
+ " '변형': 815,\n",
+ " '트릴': 816,\n",
+ " '푹': 817,\n",
+ " '부상': 818,\n",
+ " '강박장애': 819,\n",
+ " '읍니': 820,\n",
+ " '정신질환': 821,\n",
+ " '고민': 822,\n",
+ " '요통': 823,\n",
+ " '테니스': 824,\n",
+ " '삐끗': 825,\n",
+ " '뚝뚝': 826,\n",
+ " '척추관': 827,\n",
+ " '후방': 828,\n",
+ " '해석': 829,\n",
+ " '악화': 830,\n",
+ " '위암': 831,\n",
+ " '녹내장': 832,\n",
+ " '누': 833,\n",
+ " '실수': 834,\n",
+ " '쭉': 835,\n",
+ " '물집': 836,\n",
+ " '주의': 837,\n",
+ " '혹시': 838,\n",
+ " '관자놀이': 839,\n",
+ " '역류': 840,\n",
+ " '위축': 841,\n",
+ " '왼손': 842,\n",
+ " '검진': 843,\n",
+ " '응급실': 844,\n",
+ " '할머니': 845,\n",
+ " '보충': 846,\n",
+ " '마사지': 847,\n",
+ " '아무': 848,\n",
+ " '운전': 849,\n",
+ " '조직검사': 850,\n",
+ " '치질': 851,\n",
+ " '줄넘기': 852,\n",
+ " '보조': 853,\n",
+ " '사정': 854,\n",
+ " '화상': 855,\n",
+ " '콘서타': 856,\n",
+ " '오른': 857,\n",
+ " '때문': 858,\n",
+ " '타박상': 859,\n",
+ " '악몽': 860,\n",
+ " '동생': 861,\n",
+ " '매우': 862,\n",
+ " '십견': 863,\n",
+ " '검지': 864,\n",
+ " '상관관계': 865,\n",
+ " '덩어리': 866,\n",
+ " '달': 867,\n",
+ " '당화혈색소': 868,\n",
+ " '마': 869,\n",
+ " '효능': 870,\n",
+ " '이비인후과': 871,\n",
+ " '완전': 872,\n",
+ " '뒤통수': 873,\n",
+ " '식은땀': 874,\n",
+ " '다가': 875,\n",
+ " '가면': 876,\n",
+ " '거': 877,\n",
+ " '이마': 878,\n",
+ " '졸': 879,\n",
+ " '끼': 880,\n",
+ " '청소년': 881,\n",
+ " '파상풍': 882,\n",
+ " '지장': 883,\n",
+ " '우리': 884,\n",
+ " '경과': 885,\n",
+ " '면역': 886,\n",
+ " '인': 887,\n",
+ " '팔뚝': 888,\n",
+ " '어려움': 889,\n",
+ " '주파': 890,\n",
+ " '근처': 891,\n",
+ " '전혀': 892,\n",
+ " '하품': 893,\n",
+ " '방': 894,\n",
+ " '침대': 895,\n",
+ " '무언가': 896,\n",
+ " '년전': 897,\n",
+ " '가끔': 898,\n",
+ " '삶': 899,\n",
+ " '능력': 900,\n",
+ " '성욕': 901,\n",
+ " '파스': 902,\n",
+ " '뇌진탕': 903,\n",
+ " '현실': 904,\n",
+ " '낙상': 905,\n",
+ " '리보': 906,\n",
+ " '터널': 907,\n",
+ " '대인기피증': 908,\n",
+ " '기복': 909,\n",
+ " '회피': 910,\n",
+ " '정서': 911,\n",
+ " '딸아이': 912,\n",
+ " '충격파': 913,\n",
+ " '오금': 914,\n",
+ " '길이': 915,\n",
+ " '경차': 916,\n",
+ " '단술': 917,\n",
+ " '말': 918,\n",
+ " '발열': 919,\n",
+ " '단백뇨': 920,\n",
+ " '담배': 921,\n",
+ " '산소': 922,\n",
+ " '세균': 923,\n",
+ " '항체': 924,\n",
+ " '부탁': 925,\n",
+ " '단순': 926,\n",
+ " '자율신경': 927,\n",
+ " '간혹': 928,\n",
+ " '헛구역질': 929,\n",
+ " '지름': 930,\n",
+ " '죽': 931,\n",
+ " '주전': 932,\n",
+ " '백혈구': 933,\n",
+ " '마지막': 934,\n",
+ " '양': 935,\n",
+ " '목젖': 936,\n",
+ " '즙': 937,\n",
+ " '단백질': 938,\n",
+ " '테스트': 939,\n",
+ " '위험': 940,\n",
+ " '철분': 941,\n",
+ " '치': 942,\n",
+ " '무좀': 943,\n",
+ " '패턴': 944,\n",
+ " '요산': 945,\n",
+ " '학년': 946,\n",
+ " '이': 947,\n",
+ " '꿈치': 948,\n",
+ " '상실': 949,\n",
+ " '필러': 950,\n",
+ " '실내': 951,\n",
+ " '피해': 952,\n",
+ " '두': 953,\n",
+ " '판단': 954,\n",
+ " '이듭': 955,\n",
+ " '병증': 956,\n",
+ " '공황발작': 957,\n",
+ " '시선': 958,\n",
+ " '알콜중독': 959,\n",
+ " '뭉치': 960,\n",
+ " '정신분열': 961,\n",
+ " '발달': 962,\n",
+ " '탈골': 963,\n",
+ " '체외': 964,\n",
+ " '축구': 965,\n",
+ " '생리통': 966,\n",
+ " '인슐린': 967,\n",
+ " '거품': 968,\n",
+ " '안이': 969,\n",
+ " '분': 970,\n",
+ " '대학병원': 971,\n",
+ " '틴': 972,\n",
+ " '영상': 973,\n",
+ " '바': 974,\n",
+ " '부담': 975,\n",
+ " '두피': 976,\n",
+ " '신생아': 977,\n",
+ " '유독': 978,\n",
+ " '배변': 979,\n",
+ " '뭘': 980,\n",
+ " '성병': 981,\n",
+ " '치유': 982,\n",
+ " '이면': 983,\n",
+ " '양치': 984,\n",
+ " '초': 985,\n",
+ " '피멍': 986,\n",
+ " '자꾸만': 987,\n",
+ " '지면': 988,\n",
+ " '빈맥': 989,\n",
+ " '한약': 990,\n",
+ " '비용': 991,\n",
+ " '스': 992,\n",
+ " '홍조': 993,\n",
+ " '피부염': 994,\n",
+ " '진짜': 995,\n",
+ " '뇌전증': 996,\n",
+ " '용량': 997,\n",
+ " '어': 998,\n",
+ " '관련': 999,\n",
+ " '책': 1000,\n",
+ " ...}"
+ ]
+ },
+ "metadata": {
+ "tags": []
+ },
+ "execution_count": 6
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "metadata": {
+ "id": "8R4GemyJZp43",
+ "outputId": "f2fe5cb6-f7a6-4e3c-e7d1-e05d9887ef52",
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 1000
+ }
+ },
+ "source": [
+ "x_train = t.texts_to_sequences(x_train_)\n",
+ "x_train"
+ ],
+ "execution_count": 7,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "[[2033],\n",
+ " [1889, 563],\n",
+ " [380, 238, 217, 201],\n",
+ " [945, 67],\n",
+ " [423, 1298, 108, 4583],\n",
+ " [365, 150, 157, 230, 2, 21],\n",
+ " [471, 135],\n",
+ " [720],\n",
+ " [2030, 2200, 146],\n",
+ " [575, 425, 446],\n",
+ " [86, 538, 778],\n",
+ " [297, 524, 358],\n",
+ " [34],\n",
+ " [248, 61, 4, 613],\n",
+ " [54, 1157, 1884],\n",
+ " [49, 8, 47],\n",
+ " [37, 19, 589],\n",
+ " [207],\n",
+ " [18],\n",
+ " [1225, 2],\n",
+ " [384, 46, 59, 50],\n",
+ " [49, 434, 752],\n",
+ " [3371, 3372, 779, 9, 23],\n",
+ " [1344],\n",
+ " [1576, 1577, 2957, 2958, 704, 8, 89, 4006],\n",
+ " [1199, 2883, 67],\n",
+ " [109, 4557, 4558],\n",
+ " [4232, 674],\n",
+ " [13, 90],\n",
+ " [516, 32, 5647, 2338, 829],\n",
+ " [771, 72],\n",
+ " [215, 17, 40, 1652],\n",
+ " [3696, 58, 2],\n",
+ " [19, 64, 149, 90],\n",
+ " [475, 273],\n",
+ " [66, 2875, 553, 89, 1293, 97, 1548, 76],\n",
+ " [33, 323, 260],\n",
+ " [5, 166, 1031],\n",
+ " [608, 1],\n",
+ " [88, 266, 2979, 1780, 463, 1569, 163],\n",
+ " [144, 48, 2060],\n",
+ " [12, 388, 17],\n",
+ " [6284, 4, 7, 4, 39],\n",
+ " [2860, 144, 37, 133],\n",
+ " [18],\n",
+ " [941, 3046, 108, 21, 125],\n",
+ " [151, 1974, 88, 1234, 1543, 1286, 21, 991, 370],\n",
+ " [29, 1231, 188, 97],\n",
+ " [13, 908, 5784, 5785, 132],\n",
+ " [996, 132],\n",
+ " [215, 73, 1587, 1441, 1320, 984, 583],\n",
+ " [608, 1],\n",
+ " [1018, 2113, 2644, 71],\n",
+ " [12, 18, 12, 491, 1],\n",
+ " [580],\n",
+ " [42, 291, 114],\n",
+ " [475, 38],\n",
+ " [111, 108],\n",
+ " [19, 199, 1119, 569, 5235],\n",
+ " [29, 1114],\n",
+ " [2561, 577, 831, 4651, 3263],\n",
+ " [207, 590],\n",
+ " [3360, 4908],\n",
+ " [44],\n",
+ " [19, 1138, 535, 28],\n",
+ " [12, 65, 18, 1],\n",
+ " [255, 8],\n",
+ " [936, 316],\n",
+ " [139, 84, 139],\n",
+ " [6, 215, 300, 17, 1912, 215, 222, 4, 94, 4, 94, 1657, 1964],\n",
+ " [117, 357],\n",
+ " [212],\n",
+ " [30, 3412, 1872, 194],\n",
+ " [3, 1, 82, 1, 121, 4, 1],\n",
+ " [46, 502, 3648, 5931],\n",
+ " [12, 91, 1, 178, 2484, 238],\n",
+ " [1, 28],\n",
+ " [199, 430, 1490, 1547],\n",
+ " [578, 160, 762, 61],\n",
+ " [914],\n",
+ " [245, 61, 45, 79, 100, 2618, 27],\n",
+ " [13, 1698, 49],\n",
+ " [2567, 8, 96, 69],\n",
+ " [55, 78],\n",
+ " [411, 199],\n",
+ " [5847, 53, 597],\n",
+ " [4, 1, 8, 6669],\n",
+ " [321, 1771, 1684],\n",
+ " [115, 50, 925],\n",
+ " [567, 775, 189],\n",
+ " [5, 234],\n",
+ " [46, 237, 786, 10, 16, 27],\n",
+ " [3347, 1666, 2145, 13, 1856, 3348],\n",
+ " [3, 1, 60, 51, 1],\n",
+ " [207, 1267],\n",
+ " [1236, 279, 1177],\n",
+ " [145, 45],\n",
+ " [2713, 84, 148, 1331, 688],\n",
+ " [41, 16, 309],\n",
+ " [36, 96, 147],\n",
+ " [2127, 56, 58],\n",
+ " [14, 1359, 313, 97],\n",
+ " [166],\n",
+ " [736, 178, 15],\n",
+ " [1260],\n",
+ " [1510, 2695, 360, 2489, 372, 3133],\n",
+ " [15, 196, 2],\n",
+ " [332, 438, 1049],\n",
+ " [175, 5, 1338, 1043, 218],\n",
+ " [849, 545, 1075],\n",
+ " [299, 2, 319],\n",
+ " [593, 1159],\n",
+ " [4, 15, 6525, 47],\n",
+ " [12, 35, 32],\n",
+ " [758, 12, 3063, 276],\n",
+ " [3588, 1498, 1884],\n",
+ " [3],\n",
+ " [5675, 1038],\n",
+ " [388, 248, 18, 26],\n",
+ " [74, 335],\n",
+ " [13],\n",
+ " [5674, 2600, 1183, 2],\n",
+ " [6, 26, 690],\n",
+ " [66, 26, 75, 527],\n",
+ " [2101, 69, 159],\n",
+ " [4341],\n",
+ " [1712, 6538, 438],\n",
+ " [144, 1926, 1984],\n",
+ " [454],\n",
+ " [7, 3],\n",
+ " [906, 816, 1330, 2],\n",
+ " [399, 12, 3],\n",
+ " [22, 91, 355],\n",
+ " [13, 459, 97],\n",
+ " [824, 1778, 104, 161, 824, 1478, 6503, 3135],\n",
+ " [466, 776],\n",
+ " [79],\n",
+ " [762, 727, 265, 148, 620, 3660, 61],\n",
+ " [387, 618, 28],\n",
+ " [6, 2, 23],\n",
+ " [364, 588, 6, 539],\n",
+ " [88, 551, 34, 113],\n",
+ " [13, 5, 767],\n",
+ " [686, 8, 34, 1775, 2950],\n",
+ " [25, 57, 54, 1572],\n",
+ " [46, 82, 413, 1],\n",
+ " [35, 2253, 4, 229, 46, 24],\n",
+ " [2792, 74, 1],\n",
+ " [187, 23],\n",
+ " [5, 1372, 49, 72, 5, 125, 3088, 125, 9],\n",
+ " [207, 171, 90],\n",
+ " [18, 200, 137, 1045],\n",
+ " [14, 17, 6, 1508, 66, 1691, 1118],\n",
+ " [11, 538],\n",
+ " [845, 56, 27],\n",
+ " [2052, 211],\n",
+ " [62, 50],\n",
+ " [1261, 20],\n",
+ " [67],\n",
+ " [520],\n",
+ " [81, 596, 647, 90, 1248, 647, 1816],\n",
+ " [159, 2],\n",
+ " [548, 201, 49, 709, 1611, 27, 595, 73, 7, 5437],\n",
+ " [6, 1, 26, 367, 28],\n",
+ " [871, 6, 1403, 242],\n",
+ " [30, 337, 122, 7, 2004],\n",
+ " [342, 621, 31, 1168, 1019, 872, 43, 72],\n",
+ " [1248, 1503, 473],\n",
+ " [230, 204, 76],\n",
+ " [1061, 1205],\n",
+ " [921, 2614, 1333, 27],\n",
+ " [31, 1],\n",
+ " [131, 118, 313, 76],\n",
+ " [1404, 1647],\n",
+ " [4227, 4228, 923, 275, 2],\n",
+ " [4, 1137, 103],\n",
+ " [111],\n",
+ " [1850, 68, 646, 270],\n",
+ " [189, 3, 6468, 133, 1, 7, 202],\n",
+ " [92, 893, 22, 363, 614, 35],\n",
+ " [13, 233, 11],\n",
+ " [456, 15, 47],\n",
+ " [1004, 496, 24, 101, 603],\n",
+ " [79, 109, 535],\n",
+ " [312],\n",
+ " [14],\n",
+ " [212, 2],\n",
+ " [606, 84, 100],\n",
+ " [3],\n",
+ " [4805, 36, 96, 125, 264, 4806, 2880, 555, 125],\n",
+ " [15, 1520, 213, 21, 8],\n",
+ " [679, 4612, 679, 4613],\n",
+ " [99, 554, 242, 109],\n",
+ " [6, 969, 410],\n",
+ " [319, 94, 423, 747, 463],\n",
+ " [6, 377],\n",
+ " [1193, 171, 829],\n",
+ " [544, 1579],\n",
+ " [93, 259, 16, 6049],\n",
+ " [71],\n",
+ " [83, 11],\n",
+ " [175, 1344, 9, 224, 1239, 852, 186, 3645, 7, 163],\n",
+ " [45, 1310, 376],\n",
+ " [20, 359, 58, 1530],\n",
+ " [20],\n",
+ " [4, 1],\n",
+ " [3104, 1110, 2059, 972, 4284, 4285],\n",
+ " [70, 165, 24, 132, 459, 2],\n",
+ " [1208, 546],\n",
+ " [4314, 1980, 42],\n",
+ " [4416, 69],\n",
+ " [18, 354],\n",
+ " [130, 114, 67],\n",
+ " [4789],\n",
+ " [760, 2454, 810, 3, 31, 27],\n",
+ " [75],\n",
+ " [2441, 23],\n",
+ " [288, 151, 1974, 475, 150],\n",
+ " [3, 60, 788, 681],\n",
+ " [5946, 2081, 17, 1703, 39],\n",
+ " [1580, 396],\n",
+ " [21, 163, 48, 164, 86, 258, 11, 113],\n",
+ " [74, 112, 347, 26, 82, 160, 26],\n",
+ " [758, 283, 1514],\n",
+ " [3, 60, 662],\n",
+ " [299, 97, 226, 1402, 476, 356],\n",
+ " [2124, 37, 2048, 657],\n",
+ " [1040, 203],\n",
+ " [18, 2548],\n",
+ " [115, 858],\n",
+ " [87, 1263, 1269, 55, 3686],\n",
+ " [4577, 4578, 296],\n",
+ " [297, 309, 174],\n",
+ " [1631, 5243, 503, 862, 11],\n",
+ " [5884],\n",
+ " [2036, 313],\n",
+ " [104, 1910, 25, 153],\n",
+ " [898, 75, 29],\n",
+ " [7, 1865, 736, 81, 189, 235, 518],\n",
+ " [3423, 547, 308],\n",
+ " [833, 113, 20],\n",
+ " [6, 154, 168],\n",
+ " [362, 1156, 504],\n",
+ " [5812, 188, 5813],\n",
+ " [294, 2794, 2833],\n",
+ " [2889, 108, 167],\n",
+ " [1057, 21, 5492],\n",
+ " [1108, 1289],\n",
+ " [49, 29, 1],\n",
+ " [257, 393, 180, 5, 9, 1741],\n",
+ " [239, 5],\n",
+ " [585, 9],\n",
+ " [371, 3768],\n",
+ " [2306, 489, 147],\n",
+ " [15, 10, 1486],\n",
+ " [602, 205, 68, 312, 1, 743, 440],\n",
+ " [65, 16, 34, 129],\n",
+ " [1004, 67, 306],\n",
+ " [5580, 75],\n",
+ " [132, 113],\n",
+ " [352, 775, 65, 1],\n",
+ " [2428, 276, 21, 80],\n",
+ " [17],\n",
+ " [619, 37, 619, 37, 153, 4931, 947, 153],\n",
+ " [162, 33, 43, 461],\n",
+ " [596, 120],\n",
+ " [138, 173, 107],\n",
+ " [137],\n",
+ " [1698, 908, 64, 1245],\n",
+ " [656],\n",
+ " [64, 23],\n",
+ " [19, 122, 7],\n",
+ " [274, 217, 67],\n",
+ " [1161, 64, 151, 113],\n",
+ " [259, 56, 1111],\n",
+ " [262, 5, 2859],\n",
+ " [187, 3076, 2553, 125],\n",
+ " [282, 1012, 1118],\n",
+ " [1148, 655, 78],\n",
+ " [29, 2386, 206],\n",
+ " [302],\n",
+ " [136, 2948],\n",
+ " [313, 34],\n",
+ " [342, 119, 1552, 6459, 6460],\n",
+ " [224, 89, 44, 106, 236],\n",
+ " [124, 16, 74, 200, 1],\n",
+ " [1683, 29],\n",
+ " [172, 2, 1820, 357],\n",
+ " [18, 73, 1],\n",
+ " [2210, 2],\n",
+ " [318, 1317, 2],\n",
+ " [21, 23],\n",
+ " [564, 14],\n",
+ " [107, 1213],\n",
+ " [757, 501],\n",
+ " [137, 167, 1047, 2133],\n",
+ " [456, 31, 93, 608, 10, 110, 6509],\n",
+ " [6, 254],\n",
+ " [12, 1051, 1581, 97],\n",
+ " [25, 16, 90, 177],\n",
+ " [1114, 69, 775, 1311, 113],\n",
+ " [176, 5, 869, 1562, 851, 5, 942, 324, 9],\n",
+ " [1408, 1290, 287, 117],\n",
+ " [294, 198, 7],\n",
+ " [66, 20],\n",
+ " [264, 1484, 900, 1668],\n",
+ " [1502, 6, 335],\n",
+ " [4, 15, 1842, 24],\n",
+ " [4976, 1080],\n",
+ " [4, 1, 112, 265, 179, 3681],\n",
+ " [2249, 3, 39],\n",
+ " [277],\n",
+ " [109],\n",
+ " [29, 462, 75],\n",
+ " [18, 537],\n",
+ " [24, 19],\n",
+ " [4047, 2013, 155, 1096],\n",
+ " [31, 10, 3699, 30, 1334],\n",
+ " [269, 99, 390, 364],\n",
+ " [766, 2766, 4, 1157, 6126, 56, 1157, 214],\n",
+ " [63, 1764, 75],\n",
+ " [324, 803],\n",
+ " [679, 4390],\n",
+ " [262, 250, 1117],\n",
+ " [6, 129],\n",
+ " [423, 1297, 866],\n",
+ " [73, 1305, 1759],\n",
+ " [94, 74],\n",
+ " [348, 5509],\n",
+ " [349, 64],\n",
+ " [234],\n",
+ " [297, 58, 45, 129],\n",
+ " [6, 164, 6, 1427, 3925, 40, 39],\n",
+ " [137, 1590],\n",
+ " [579, 417],\n",
+ " [2736, 726, 323, 192],\n",
+ " [36, 5, 9, 23],\n",
+ " [44, 244, 99],\n",
+ " [1533, 309, 457, 42, 6301, 1390],\n",
+ " [233, 627, 697],\n",
+ " [4, 15, 371, 238, 448, 21, 105, 27],\n",
+ " [611, 275, 316, 66, 1652],\n",
+ " [70, 899, 90, 736, 444],\n",
+ " [1024, 199, 1879, 5119, 78],\n",
+ " [17, 57, 4, 272],\n",
+ " [4000, 792],\n",
+ " [30],\n",
+ " [267, 268, 15],\n",
+ " [175, 221],\n",
+ " [3, 2234, 94, 1],\n",
+ " [187],\n",
+ " [73, 126, 21, 1601, 108, 1177],\n",
+ " [824, 1265, 104, 87, 377],\n",
+ " [526, 1155, 6648, 47],\n",
+ " [562, 125],\n",
+ " [208, 366, 1445, 75],\n",
+ " [6, 15, 10, 1],\n",
+ " [344, 1],\n",
+ " [159, 523],\n",
+ " [109, 365],\n",
+ " [481, 252, 116, 418, 245, 1211, 70, 600, 534],\n",
+ " [486, 518],\n",
+ " [2775, 68],\n",
+ " [2685, 38, 62],\n",
+ " [92, 6, 302, 212],\n",
+ " [485, 120, 25, 402, 694],\n",
+ " [763],\n",
+ " [34, 110, 1],\n",
+ " [2, 261],\n",
+ " [1997, 673, 86, 682],\n",
+ " [84],\n",
+ " [977, 2418],\n",
+ " [11],\n",
+ " [1443, 2058, 527],\n",
+ " [3624, 1383, 10, 135, 57],\n",
+ " [485, 120, 10, 93, 1, 41],\n",
+ " [83, 11, 273, 105, 27],\n",
+ " [15, 10, 23, 3529, 1450],\n",
+ " [1082, 21],\n",
+ " [383, 67, 2],\n",
+ " [264, 3384, 244, 1374],\n",
+ " [6, 17, 35, 368],\n",
+ " [1203, 468],\n",
+ " [140, 244],\n",
+ " [5, 313],\n",
+ " [61, 315, 1384],\n",
+ " [1071, 640, 1459, 7, 20, 195, 1532],\n",
+ " [550, 90],\n",
+ " [4, 2721],\n",
+ " [130, 102],\n",
+ " [86, 2374, 1887, 405, 14],\n",
+ " [4],\n",
+ " [4, 15, 10, 752, 58, 129],\n",
+ " [968, 1391, 21],\n",
+ " [12, 18],\n",
+ " [88, 1234],\n",
+ " [1131, 995, 4, 3625, 1872],\n",
+ " [380, 1015, 2],\n",
+ " [16, 915, 160, 46],\n",
+ " [4017],\n",
+ " [1146, 1487, 282, 1660],\n",
+ " [700, 3556, 62],\n",
+ " [4, 15, 10, 192, 741, 381, 206, 82, 1],\n",
+ " [5, 238, 900],\n",
+ " [1296, 1767],\n",
+ " [514, 1325, 270, 193],\n",
+ " [215, 320, 363],\n",
+ " [5656, 18, 29],\n",
+ " [154, 168, 960, 18],\n",
+ " [3, 162, 33, 60, 133, 468],\n",
+ " [262, 1790, 20, 1195, 213, 170, 339, 1302, 37, 5],\n",
+ " [137, 2268, 2985, 4044, 1586, 35, 4045],\n",
+ " [479, 807],\n",
+ " [14, 1199],\n",
+ " [3, 3590, 51],\n",
+ " [197, 714, 2900, 232, 1419],\n",
+ " [75, 1407],\n",
+ " [19, 348, 94],\n",
+ " [4552, 707, 4553, 4554, 1477, 2546, 1477, 35, 1477, 2403, 218, 99, 4555],\n",
+ " [1004, 67],\n",
+ " [37, 1119, 19],\n",
+ " [3, 33],\n",
+ " [75],\n",
+ " [544, 1221],\n",
+ " [13, 41],\n",
+ " [180, 9, 513],\n",
+ " [672, 781, 2301, 50, 1192],\n",
+ " [191, 191],\n",
+ " [20, 18, 1],\n",
+ " [5613, 733, 756, 50],\n",
+ " [495, 59],\n",
+ " [159, 597],\n",
+ " [303],\n",
+ " [4, 15, 3, 1, 61, 1620, 7],\n",
+ " [22, 6222, 725, 55, 98],\n",
+ " [65, 26, 104, 152],\n",
+ " [5798, 313],\n",
+ " [36, 5, 9, 297, 58, 195, 646, 885, 357],\n",
+ " [1395, 477, 466, 2421],\n",
+ " [4, 373],\n",
+ " [1008, 71, 1497, 314],\n",
+ " [160, 30, 10, 680, 270, 1984],\n",
+ " [42, 1, 446],\n",
+ " [104, 1927, 68, 6278, 415, 288, 474],\n",
+ " [155],\n",
+ " [6616],\n",
+ " [15, 8],\n",
+ " [572, 35, 886, 577, 2098],\n",
+ " [495, 59, 791, 982, 41, 249, 107],\n",
+ " [6, 15, 65, 453, 201],\n",
+ " [1438, 122, 166],\n",
+ " [1222, 684],\n",
+ " [42],\n",
+ " [13, 8],\n",
+ " [182, 266, 743, 4403, 4404, 94],\n",
+ " [3],\n",
+ " [18, 2691],\n",
+ " [6, 242, 108],\n",
+ " [162, 33, 43, 10, 296],\n",
+ " [546, 7],\n",
+ " [369, 19, 238, 41, 5258, 660, 1190, 11, 53],\n",
+ " [2306, 5],\n",
+ " [447],\n",
+ " [1],\n",
+ " [22, 624, 808, 32, 1233],\n",
+ " [1154, 11],\n",
+ " [2970, 2971],\n",
+ " [427, 59, 1],\n",
+ " [267, 268, 373, 10, 1, 505, 498, 487],\n",
+ " [2073, 67],\n",
+ " [6, 15, 4, 15],\n",
+ " [1921, 1063, 10, 98, 56],\n",
+ " [661, 14, 108],\n",
+ " [42, 230, 801, 1072],\n",
+ " [42, 31, 110, 1, 2],\n",
+ " [64, 736, 50],\n",
+ " [304, 282, 349],\n",
+ " [1730, 3998, 1047, 129],\n",
+ " [6, 32],\n",
+ " [176, 269],\n",
+ " [119, 804, 1219],\n",
+ " [1237, 188, 97],\n",
+ " [64, 238, 2687],\n",
+ " [1575, 588, 559],\n",
+ " [208, 560, 86, 2462, 19, 27],\n",
+ " [3],\n",
+ " [204, 96, 1160],\n",
+ " [93, 95, 203],\n",
+ " [188, 71, 228],\n",
+ " [2157, 2716, 2161],\n",
+ " [3494, 2570],\n",
+ " [504, 503, 5503, 989],\n",
+ " [379, 251, 235, 518, 2645],\n",
+ " [4194],\n",
+ " [30, 337],\n",
+ " [280],\n",
+ " [187],\n",
+ " [4941, 230, 431, 124, 4942, 4943],\n",
+ " [884, 56, 2556, 647, 2462, 330],\n",
+ " [36, 41, 47],\n",
+ " [887, 2602, 9],\n",
+ " [392, 3882, 2880, 3883, 640],\n",
+ " [831, 196, 2],\n",
+ " [3012, 717, 101],\n",
+ " [1072, 26, 2552, 359, 52],\n",
+ " [155, 585],\n",
+ " [3569, 8, 90, 1046],\n",
+ " [2483, 847, 1139, 78],\n",
+ " [17],\n",
+ " [485, 120, 25, 402, 694],\n",
+ " [112, 3166],\n",
+ " [1422],\n",
+ " [813, 163],\n",
+ " [36, 2275, 149],\n",
+ " [1293, 5941, 5942, 2747, 198, 1020, 1975],\n",
+ " [6, 17],\n",
+ " [512, 20, 636],\n",
+ " [52, 228, 170, 2324],\n",
+ " [4914, 1478, 4915],\n",
+ " [2881, 2312, 158],\n",
+ " [12, 363, 230],\n",
+ " [692, 1151],\n",
+ " [773, 33, 114, 103],\n",
+ " [663, 146, 109, 45, 79, 2114],\n",
+ " [2621],\n",
+ " [12, 16],\n",
+ " [70, 165, 593],\n",
+ " [2700],\n",
+ " [56],\n",
+ " [37, 2459, 3112, 509, 494, 149, 5, 534, 105],\n",
+ " [1753, 4792, 4793, 3309],\n",
+ " [3, 60, 43, 90, 50],\n",
+ " [65, 210],\n",
+ " [1202, 209, 3206, 4489, 1],\n",
+ " [1362, 556, 57, 128],\n",
+ " [22, 1409, 120, 25],\n",
+ " [18, 73, 190, 1547, 2],\n",
+ " [2313, 425, 7, 3151],\n",
+ " [4, 28],\n",
+ " [1492, 204],\n",
+ " [156, 21],\n",
+ " [307],\n",
+ " [247, 1711, 43, 71, 10, 527],\n",
+ " [207, 590, 1922, 956, 23],\n",
+ " [700, 140],\n",
+ " [49],\n",
+ " [516, 39, 19],\n",
+ " [13, 96, 240],\n",
+ " [136, 1281, 474],\n",
+ " [1560, 214],\n",
+ " [134, 1266, 51, 1038],\n",
+ " [251, 571, 63, 1],\n",
+ " [14, 442, 53],\n",
+ " [44],\n",
+ " [176, 1553],\n",
+ " [1857, 3138, 1789],\n",
+ " [4, 3, 1, 472, 9, 591, 27],\n",
+ " [302, 10],\n",
+ " [4020, 155, 89],\n",
+ " [1327, 2, 260],\n",
+ " [214, 7],\n",
+ " [3207, 46, 293, 77, 77, 265, 1031, 239, 51, 4],\n",
+ " [484, 189, 95, 1145, 2],\n",
+ " [20, 41, 249],\n",
+ " [132, 75, 459, 48, 1117],\n",
+ " [180, 5, 1971, 4237, 9],\n",
+ " [242],\n",
+ " [778, 474],\n",
+ " [97, 636, 5, 125, 5, 767],\n",
+ " [3584, 814],\n",
+ " [215, 2483, 32, 220, 969, 222],\n",
+ " [96, 69, 297, 58],\n",
+ " [4631, 620],\n",
+ " [15, 10, 991, 474, 415, 105],\n",
+ " [1324, 1022, 2118, 7],\n",
+ " [6555, 310, 441, 182],\n",
+ " [303],\n",
+ " [313, 1825],\n",
+ " [112, 2115],\n",
+ " [20],\n",
+ " [386],\n",
+ " [36, 393, 871, 5],\n",
+ " [154, 168],\n",
+ " [544, 127],\n",
+ " [418, 5, 263, 93, 4796, 9],\n",
+ " [2767, 956, 161, 256, 2440, 6123, 46, 265],\n",
+ " [75],\n",
+ " [4, 15, 72, 7, 1, 505, 7, 587, 1],\n",
+ " [6, 15],\n",
+ " [155, 67, 184, 1099, 184, 496, 24, 155, 4778],\n",
+ " [140, 161],\n",
+ " [60, 392, 193],\n",
+ " [1792, 110, 27],\n",
+ " [916, 917, 51, 16, 58],\n",
+ " [603],\n",
+ " [916, 917],\n",
+ " [57, 3, 39],\n",
+ " [608, 152, 750],\n",
+ " [3735, 10, 23],\n",
+ " [984, 2896, 6, 108, 365],\n",
+ " [1123, 284],\n",
+ " [227, 947],\n",
+ " [20, 1351, 148, 620],\n",
+ " [3832, 3833, 327, 9, 2288, 1101, 1942],\n",
+ " [81, 421],\n",
+ " [7, 358, 669, 975, 744, 3844],\n",
+ " [10],\n",
+ " [131, 118, 345, 59, 1400],\n",
+ " [30, 414, 1],\n",
+ " [19, 18, 97],\n",
+ " [38, 4988, 62],\n",
+ " [148, 761],\n",
+ " [1424, 1558, 3920, 62],\n",
+ " [4, 15, 293, 231, 1491, 1098, 922, 7],\n",
+ " [190, 203],\n",
+ " [3, 1],\n",
+ " [22, 6023, 2605, 1246, 804, 537, 1812],\n",
+ " [81, 95, 3427, 2192],\n",
+ " [207, 77, 10, 6, 488, 76, 215, 359, 58],\n",
+ " [435, 3733, 30, 114],\n",
+ " [22, 82, 616, 1, 16, 6445, 128],\n",
+ " [87, 907, 68, 87, 33],\n",
+ " [13, 597],\n",
+ " [56, 28],\n",
+ " [144, 6, 15, 72],\n",
+ " [333, 6, 2, 1041, 40],\n",
+ " [49, 193, 5558],\n",
+ " [183, 359, 52],\n",
+ " [512, 19, 62],\n",
+ " [232, 3181, 2319],\n",
+ " [1010, 106, 382, 801],\n",
+ " [17, 1, 7, 8, 7],\n",
+ " [12, 1716, 5908, 363],\n",
+ " [54, 1929],\n",
+ " [1545, 1800, 1603, 1737],\n",
+ " [42, 31, 25, 10, 98, 135],\n",
+ " [3576, 1084],\n",
+ " [17, 361, 43],\n",
+ " [42, 561],\n",
+ " [12, 888, 199],\n",
+ " [333, 6, 198, 27, 214],\n",
+ " [191, 53],\n",
+ " [99],\n",
+ " [333, 6, 387],\n",
+ " [390, 110, 2412, 1032],\n",
+ " [4546, 2473, 2284],\n",
+ " [91, 347],\n",
+ " [965, 403, 355],\n",
+ " [603, 7, 6, 4506],\n",
+ " [19, 929],\n",
+ " [518, 88, 34, 253],\n",
+ " [594, 24],\n",
+ " [54, 948, 1],\n",
+ " [615, 591, 8, 28],\n",
+ " [823, 438, 8],\n",
+ " [1564, 127, 1317, 2],\n",
+ " [4867, 1126, 125, 5, 562],\n",
+ " [145, 164, 11, 11, 191],\n",
+ " [30, 60, 135],\n",
+ " [427, 839, 6, 17, 1],\n",
+ " [44, 8, 89],\n",
+ " [88, 18, 1],\n",
+ " [4102, 3014, 629, 80, 4103, 3015],\n",
+ " [245, 1824, 937, 147],\n",
+ " [3082, 1459, 4532],\n",
+ " [1227],\n",
+ " [4115],\n",
+ " [252, 421, 72],\n",
+ " [214, 87, 907, 68, 449],\n",
+ " [18, 227, 196, 5272],\n",
+ " [4321, 1328, 2462, 4322],\n",
+ " [951, 1461, 163, 208, 149],\n",
+ " [2, 64],\n",
+ " [408, 132, 227],\n",
+ " [157, 183, 179],\n",
+ " [724, 556, 112, 40, 4, 1],\n",
+ " [61, 66],\n",
+ " [453, 7, 235],\n",
+ " [271],\n",
+ " [64, 264],\n",
+ " [197, 1612, 21, 2505, 1751],\n",
+ " [516, 3572, 2690, 464, 1452],\n",
+ " [1, 23],\n",
+ " [1366, 622, 844, 48, 499, 1228],\n",
+ " [19, 50],\n",
+ " [175],\n",
+ " [49, 5],\n",
+ " [1011, 47],\n",
+ " [452, 67],\n",
+ " [484, 3706, 21],\n",
+ " [1214],\n",
+ " [17, 1],\n",
+ " [82, 1528, 100, 2254, 122],\n",
+ " [362, 105, 307],\n",
+ " [84, 430, 165, 24],\n",
+ " [1625, 1],\n",
+ " [887, 2602, 1274],\n",
+ " [1253],\n",
+ " [207, 25, 1, 23],\n",
+ " [622],\n",
+ " [664, 24, 8, 28, 105],\n",
+ " [21, 114, 543, 27],\n",
+ " [22, 91, 179],\n",
+ " [966, 76, 301],\n",
+ " [17, 65, 1],\n",
+ " [2621],\n",
+ " [207, 15, 1, 147, 28],\n",
+ " [262, 250, 510],\n",
+ " [169, 681, 163, 31, 39],\n",
+ " [99],\n",
+ " [20, 156],\n",
+ " [269, 1403, 79, 18],\n",
+ " [140, 271, 1037, 24, 240, 185, 68, 105],\n",
+ " [1355],\n",
+ " [934, 372, 76, 2670, 450],\n",
+ " [54, 1526, 561],\n",
+ " [7, 938, 846],\n",
+ " [5, 304, 35, 63, 265],\n",
+ " [3, 1],\n",
+ " [302, 230],\n",
+ " [15, 6609, 24],\n",
+ " [35, 76, 146],\n",
+ " [1354, 90],\n",
+ " [283, 13],\n",
+ " [1227],\n",
+ " [386, 72, 324, 125, 1536, 2872],\n",
+ " [2033, 136, 5],\n",
+ " [115, 768],\n",
+ " [512, 632, 5, 791, 982],\n",
+ " [29],\n",
+ " [3, 10],\n",
+ " [294, 791, 982, 27, 7, 28],\n",
+ " [3, 209, 33, 43, 221],\n",
+ " [5549, 5550, 1126],\n",
+ " [299, 38, 24, 70, 165, 24, 38, 24],\n",
+ " [11, 121],\n",
+ " [2481, 50],\n",
+ " [30, 4561],\n",
+ " [160, 3, 1],\n",
+ " [118, 5, 1757, 1985, 23],\n",
+ " [1110, 259, 66],\n",
+ " [57, 124, 30, 1, 690],\n",
+ " [1935, 2521, 3251, 1477],\n",
+ " [37, 1],\n",
+ " [266, 99, 2593, 1396, 2645],\n",
+ " [81, 2043, 75, 665],\n",
+ " [116, 136, 4275, 9, 715, 106],\n",
+ " [261, 203, 143, 109, 3908, 2],\n",
+ " [3, 148, 10, 527],\n",
+ " [12, 74],\n",
+ " [29, 29, 94, 5232],\n",
+ " [406],\n",
+ " [180, 5, 9, 125, 257, 5],\n",
+ " [45, 66],\n",
+ " [1687, 266, 41, 243, 97, 94],\n",
+ " [6, 154, 168, 76],\n",
+ " [368, 675, 2175, 219, 52],\n",
+ " [1763, 779, 3967, 57, 9],\n",
+ " [34],\n",
+ " [1954, 154, 2305, 3864, 2305, 840, 24],\n",
+ " [138, 352],\n",
+ " [322, 19, 62, 1012],\n",
+ " [728, 101, 41],\n",
+ " [166, 23],\n",
+ " [1953, 1403, 99],\n",
+ " [4386, 4387, 57, 4388],\n",
+ " [29, 18, 1],\n",
+ " [190, 35, 110, 1],\n",
+ " [379, 22, 14, 1067, 3719],\n",
+ " [3, 6357, 725, 10, 2233, 98],\n",
+ " [322, 19, 68, 64, 94],\n",
+ " [6, 154, 168, 76, 129],\n",
+ " [673, 2318, 4],\n",
+ " [700, 2, 140, 310, 139, 285],\n",
+ " [184, 261, 1427],\n",
+ " [166],\n",
+ " [30, 5995],\n",
+ " [582, 4],\n",
+ " [4317, 2350, 2344, 1462, 2461, 158],\n",
+ " [578, 350, 3254, 92, 1673],\n",
+ " [670],\n",
+ " [64, 122],\n",
+ " [30, 2, 90, 1046],\n",
+ " [898, 3433, 123, 2637, 1452, 536],\n",
+ " [92, 735],\n",
+ " [1023, 2],\n",
+ " [663, 146],\n",
+ " [3282, 176],\n",
+ " [4139, 21, 171, 829],\n",
+ " [1216, 831],\n",
+ " [331, 611],\n",
+ " [1044, 1],\n",
+ " [247, 151, 43, 65, 58, 2],\n",
+ " [390, 296],\n",
+ " [344, 465],\n",
+ " [74, 1, 135],\n",
+ " [385, 115, 768, 219, 201, 75, 53, 45, 79, 13],\n",
+ " [1022, 1252, 622, 19, 1081, 62],\n",
+ " [132],\n",
+ " [4, 108],\n",
+ " [30, 52, 642, 30, 1],\n",
+ " [112, 1, 16, 58, 471],\n",
+ " [596, 814, 358, 491, 455],\n",
+ " [570, 172],\n",
+ " [959, 1034],\n",
+ " [1292],\n",
+ " [16, 1],\n",
+ " [359],\n",
+ " [1078, 40, 39],\n",
+ " [521, 78],\n",
+ " [60, 2363, 24, 3, 33],\n",
+ " [6, 1328],\n",
+ " [475, 85, 127],\n",
+ " [4, 15, 196, 399, 229, 163],\n",
+ " [3, 3663, 1053, 5, 93, 598, 618, 890],\n",
+ " [724, 4, 70, 865],\n",
+ " [255, 9],\n",
+ " [1966, 2320, 62],\n",
+ " [3342, 3343, 575, 4863, 1647, 463, 27],\n",
+ " [208, 29, 92, 2054],\n",
+ " [3888, 3889, 327, 9],\n",
+ " [134, 2299, 101, 197, 2300, 3851, 1733],\n",
+ " [56, 1406],\n",
+ " [255],\n",
+ " [46, 1388, 101, 964, 913, 231, 6531],\n",
+ " [1022, 3641, 3642, 1920, 857],\n",
+ " [246, 308, 266],\n",
+ " [65, 592, 93, 308, 7, 122],\n",
+ " [255, 1499],\n",
+ " [74, 1],\n",
+ " [828, 696, 872, 43, 442, 10],\n",
+ " [855, 855, 805],\n",
+ " [255, 96, 101, 253],\n",
+ " [13],\n",
+ " [17, 247, 151, 43, 10],\n",
+ " [29, 34, 100],\n",
+ " [15, 10, 221],\n",
+ " [2390, 830],\n",
+ " [46, 476, 24, 6596, 6597, 1220],\n",
+ " [14, 893, 260],\n",
+ " [2254, 6, 15, 122],\n",
+ " [209, 558],\n",
+ " [115, 115],\n",
+ " [1123],\n",
+ " [567, 21, 171],\n",
+ " [66, 254, 20],\n",
+ " [2131],\n",
+ " [3, 1088],\n",
+ " [436, 6, 222, 6],\n",
+ " [84, 19],\n",
+ " [252, 1465, 4794, 411, 985, 108, 21],\n",
+ " [9, 36, 96, 259, 253],\n",
+ " [180, 5, 4443, 135],\n",
+ " [454, 45, 416],\n",
+ " [83, 5412, 3141, 197, 1610],\n",
+ " [19, 92],\n",
+ " [514, 602, 205, 68, 122],\n",
+ " [331, 3008],\n",
+ " [1347, 470, 1347, 2533, 82],\n",
+ " [819, 96],\n",
+ " [3, 377],\n",
+ " [351, 1009, 174, 38, 1897, 1503],\n",
+ " [111],\n",
+ " [408, 162, 33, 32, 43, 323, 853, 1383, 1056, 1052],\n",
+ " [958, 563],\n",
+ " [11],\n",
+ " [210, 53],\n",
+ " [162, 33, 1053, 55, 91, 52, 1322],\n",
+ " [136, 1345, 2348, 136, 5, 5],\n",
+ " [22, 56, 412],\n",
+ " [6650],\n",
+ " [215, 16, 6461, 74, 346, 2255, 1902, 124, 97, 6462, 925],\n",
+ " [13, 1160, 219, 115, 201],\n",
+ " [108, 51, 1334, 378, 391],\n",
+ " [452, 2039, 124, 4801, 5, 218],\n",
+ " [262, 57, 549, 3807],\n",
+ " [54, 128],\n",
+ " [44, 308],\n",
+ " [233, 2187],\n",
+ " [36, 5, 9, 785, 45, 460],\n",
+ " [329, 400],\n",
+ " [93, 962, 2717, 66],\n",
+ " [871, 1403, 390, 21, 643, 27],\n",
+ " [3265, 114, 67],\n",
+ " [222, 181],\n",
+ " [295, 4986, 653, 39],\n",
+ " [199, 368, 464, 234],\n",
+ " [85, 374, 21],\n",
+ " [4],\n",
+ " [20, 6],\n",
+ " [138, 173, 8, 22, 35, 26, 48],\n",
+ " [199, 71, 301, 5723, 3376, 78],\n",
+ " [1070, 782],\n",
+ " [60, 51, 752, 1, 240],\n",
+ " [19, 1108, 1289, 376],\n",
+ " [38, 24, 1068],\n",
+ " [13, 123],\n",
+ " [4, 198, 8],\n",
+ " [869, 1718, 106, 105],\n",
+ " [148, 173, 1181, 70, 600, 47],\n",
+ " [230],\n",
+ " [2577],\n",
+ " [85, 127],\n",
+ " [19, 20],\n",
+ " [2],\n",
+ " [55, 190, 110],\n",
+ " [25, 98, 8],\n",
+ " [4, 15, 10, 192, 385, 628, 163],\n",
+ " [2250, 25, 10],\n",
+ " [132, 5, 69],\n",
+ " [566, 21],\n",
+ " [22, 3, 1652],\n",
+ " [1776, 103],\n",
+ " [22, 16, 1087, 32, 336, 430, 6190, 6191, 282],\n",
+ " [19, 670, 865],\n",
+ " [3],\n",
+ " [295, 4586, 315, 114],\n",
+ " [27, 7, 151],\n",
+ " [13, 2701, 90, 3536, 23],\n",
+ " [324, 1417, 9, 4749, 425],\n",
+ " [702, 1491, 117, 497, 286],\n",
+ " [45, 79, 812, 201, 27],\n",
+ " [4, 825, 8, 1, 41],\n",
+ " [11, 150, 290],\n",
+ " [294, 10, 310, 8, 28],\n",
+ " [369, 210, 129, 301],\n",
+ " [3319, 46, 31, 956, 96, 9, 47],\n",
+ " [92, 2],\n",
+ " [17],\n",
+ " [86, 7, 4, 825],\n",
+ " [30, 3637, 192, 752, 765],\n",
+ " [681, 1342, 453, 7, 1098, 922, 7, 27],\n",
+ " [182],\n",
+ " [10, 445, 1],\n",
+ " [29, 522],\n",
+ " [2001, 53],\n",
+ " [11, 574, 29],\n",
+ " [73, 1189, 1199, 1132],\n",
+ " [417, 97, 3285, 9],\n",
+ " [1364, 1017],\n",
+ " [2034, 111, 3226, 111, 3227],\n",
+ " [42, 331, 124, 76, 805],\n",
+ " [106, 2079, 838, 34, 451, 517],\n",
+ " [14, 248, 976, 1818, 440, 2493],\n",
+ " [11, 1094, 34, 1095, 919],\n",
+ " [30, 40, 1198, 135, 1524, 216, 10],\n",
+ " [41, 280],\n",
+ " [4, 15, 293],\n",
+ " [29, 843, 181, 455, 1564, 27],\n",
+ " [169],\n",
+ " [371, 471, 890, 231, 2, 830],\n",
+ " [138, 173, 642, 443],\n",
+ " [137, 1111, 746],\n",
+ " [12, 3675, 1],\n",
+ " [3, 338, 137, 1111, 797],\n",
+ " [63, 1],\n",
+ " [12, 624, 179, 48],\n",
+ " [19, 622, 44, 37, 36, 393, 871, 5],\n",
+ " [350, 1, 301],\n",
+ " [289, 26, 3532, 2491, 2],\n",
+ " [1669, 1669],\n",
+ " [176, 5],\n",
+ " [1873, 3417, 1055],\n",
+ " [12, 3, 1],\n",
+ " [12, 17],\n",
+ " [13],\n",
+ " [1201, 251, 1040, 1978, 174, 2904],\n",
+ " [1085, 48],\n",
+ " [648],\n",
+ " [63, 346, 978, 75],\n",
+ " [30, 33, 408, 1, 1984, 474],\n",
+ " [54, 719, 361, 37, 1506, 2718, 181],\n",
+ " [71, 767],\n",
+ " [264, 541, 2564, 1382, 122],\n",
+ " [367, 605, 3355, 199, 2592],\n",
+ " [669, 1053, 116],\n",
+ " [36, 5, 9, 14],\n",
+ " [120, 726],\n",
+ " [19, 1160],\n",
+ " [1955, 1550, 3867, 2870],\n",
+ " [1123],\n",
+ " [396, 5, 69],\n",
+ " [15, 23],\n",
+ " [1382, 1188, 685],\n",
+ " [4, 15, 1],\n",
+ " [486],\n",
+ " [109, 616, 871, 150, 149],\n",
+ " [661, 204, 479],\n",
+ " [557, 291, 40, 1236, 1],\n",
+ " [155, 9],\n",
+ " [1488, 24, 8],\n",
+ " [264, 47],\n",
+ " [229, 2511, 628],\n",
+ " [405, 1119],\n",
+ " [73, 126, 850],\n",
+ " [40, 39, 1, 103],\n",
+ " [2696, 2095],\n",
+ " [484, 48, 364],\n",
+ " [324, 69, 313, 250, 5],\n",
+ " [1552, 1612, 69],\n",
+ " ...]"
+ ]
+ },
+ "metadata": {
+ "tags": []
+ },
+ "execution_count": 7
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "metadata": {
+ "scrolled": true,
+ "id": "rPl6D8_xZp46",
+ "outputId": "e655df7d-0887-4cad-98af-27c4a657309d",
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 34
+ }
+ },
+ "source": [
+ "sequence_length = 10\n",
+ "trunc_type = 'post'\n",
+ "padding_type = 'post'\n",
+ "padded_x_train = tf.keras.preprocessing.sequence.pad_sequences(x_train, truncating=trunc_type, padding=padding_type, maxlen=sequence_length)\n",
+ "padded_x_train.shape"
+ ],
+ "execution_count": 8,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "(16336, 10)"
+ ]
+ },
+ "metadata": {
+ "tags": []
+ },
+ "execution_count": 8
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "metadata": {
+ "id": "Q9lxcUfOZp49",
+ "outputId": "1d33432d-38e5-4b7c-a83b-6247d8c77a2b",
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 136
+ }
+ },
+ "source": [
+ "x_test = t.texts_to_sequences(x_test_)\n",
+ "padded_x_test = tf.keras.preprocessing.sequence.pad_sequences(x_test, truncating=trunc_type, padding=padding_type, maxlen=sequence_length)\n",
+ "padded_x_test"
+ ],
+ "execution_count": 9,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "array([[ 275, 4955, 0, ..., 0, 0, 0],\n",
+ " [ 30, 361, 10, ..., 0, 0, 0],\n",
+ " [ 160, 524, 32, ..., 0, 0, 0],\n",
+ " ...,\n",
+ " [ 16, 0, 0, ..., 0, 0, 0],\n",
+ " [1796, 3, 0, ..., 0, 0, 0],\n",
+ " [ 28, 0, 0, ..., 0, 0, 0]], dtype=int32)"
+ ]
+ },
+ "metadata": {
+ "tags": []
+ },
+ "execution_count": 9
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "metadata": {
+ "id": "oxfEGMCwrRLO"
+ },
+ "source": [
+ "from sklearn.utils import class_weight\n",
+ "weight = class_weight.compute_class_weight('balanced', np.unique(y_train), y_train)\n",
+ "weight = {i : weight[i] for i in range(26)}"
+ ],
+ "execution_count": 10,
+ "outputs": []
+ },
+ {
+ "cell_type": "code",
+ "metadata": {
+ "id": "9co_FKiXtpp7",
+ "outputId": "8f18ba24-a415-4293-e302-84888c2f96be",
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 51
+ }
+ },
+ "source": [
+ "np.unique(y_train)"
+ ],
+ "execution_count": 11,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,\n",
+ " 17, 18, 19, 20, 21, 22, 23, 24, 25])"
+ ]
+ },
+ "metadata": {
+ "tags": []
+ },
+ "execution_count": 11
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "metadata": {
+ "id": "zM16G4uIZp5A",
+ "outputId": "46655384-3b79-4e94-f6d7-6843fc8bcea0",
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 34
+ }
+ },
+ "source": [
+ "y_train = keras.utils.to_categorical(y_train)\n",
+ "y_test = keras.utils.to_categorical(y_test)\n",
+ "y_train.shape"
+ ],
+ "execution_count": 12,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "(16336, 26)"
+ ]
+ },
+ "metadata": {
+ "tags": []
+ },
+ "execution_count": 12
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "metadata": {
+ "id": "YOZ86XKjPYcn"
+ },
+ "source": [
+ "class BahdanauAttention(tf.keras.Model):\n",
+ " def __init__(self, units):\n",
+ " super(BahdanauAttention, self).__init__()\n",
+ " self.W1 = Dense(units)\n",
+ " self.W2 = Dense(units)\n",
+ " self.V = Dense(1)\n",
+ "\n",
+ " def call(self, values, query): # 단, key와 value는 같음\n",
+ " # query shape == (batch_size, hidden size)\n",
+ " # hidden_with_time_axis shape == (batch_size, 1, hidden size)\n",
+ " # score 계산을 위해 뒤에서 할 덧셈을 위해서 차원을 변경해줍니다.\n",
+ " hidden_with_time_axis = tf.expand_dims(query, 1)\n",
+ "\n",
+ " # score shape == (batch_size, max_length, 1)\n",
+ " # we get 1 at the last axis because we are applying score to self.V\n",
+ " # the shape of the tensor before applying self.V is (batch_size, max_length, units)\n",
+ " score = self.V(tf.nn.tanh(\n",
+ " self.W1(values) + self.W2(hidden_with_time_axis)))\n",
+ "\n",
+ " # attention_weights shape == (batch_size, max_length, 1)\n",
+ " attention_weights = tf.nn.softmax(score, axis=1)\n",
+ "\n",
+ " # context_vector shape after sum == (batch_size, hidden_size)\n",
+ " context_vector = attention_weights * values\n",
+ " context_vector = tf.reduce_sum(context_vector, axis=1)\n",
+ "\n",
+ " return context_vector, attention_weights"
+ ],
+ "execution_count": 13,
+ "outputs": []
+ },
+ {
+ "cell_type": "code",
+ "metadata": {
+ "scrolled": true,
+ "id": "9cpjxmyOZp5C",
+ "outputId": "02e79a8b-2428-44f9-9bff-62759cabb4eb",
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 561
+ }
+ },
+ "source": [
+ "from tensorflow.keras.layers import Input, Embedding, LSTM, Dense, Bidirectional, Dropout, Concatenate\n",
+ "\n",
+ "embedding_dim = 1024\n",
+ "\n",
+ "## LSTM model\n",
+ "# model = keras.models.Sequential([\n",
+ "# Embedding(vocab_size, embedding_dim),\n",
+ "# #Bidirectional(LSTM(1024, return_sequences=True)),\n",
+ "# Bidirectional(LSTM(512)),\n",
+ "# #Dense(256, activation='relu'),\n",
+ "# #Dropout(0.5),\n",
+ "# Dense(256, activation='relu'),\n",
+ "# Dropout(0.25),\n",
+ "# Dense(64, activation='relu'),\n",
+ "# Dropout(0.25),\n",
+ "# Dense(26, activation='softmax')\n",
+ "# ])\n",
+ "\n",
+ "\n",
+ "# LSTM + Attention model\n",
+ "input = Input(shape=(sequence_length,))\n",
+ "embed = Embedding(vocab_size, embedding_dim, input_length=sequence_length, )(input)\n",
+ "lstm = Bidirectional(LSTM(512, dropout=0.25, return_sequences = True))(embed)\n",
+ "lstm, forward_h, forward_c, backward_h, backward_c = Bidirectional \\\n",
+ " (LSTM(512, dropout=0.25, return_sequences=True, return_state=True))(lstm)\n",
+ "state_h = Concatenate()([forward_h, backward_h]) # 은닉 상태\n",
+ "state_c = Concatenate()([forward_c, backward_c]) # 셀 상태\n",
+ "\n",
+ "## add attention layers\n",
+ "attention = BahdanauAttention(256) # 가중치 크기 정의\n",
+ "context_vector, attention_weights = attention(lstm, state_h)\n",
+ "\n",
+ "x = Dense(256, activation='relu')(context_vector)\n",
+ "x = Dropout(0.25)(x)\n",
+ "x = Dense(64, activation='relu')(x)\n",
+ "x = Dropout(0.25)(x)\n",
+ "output = Dense(26, activation='softmax')(x)\n",
+ "\n",
+ "model = tf.keras.Model(input, output)\n",
+ "\n",
+ "\n",
+ "import datetime\n",
+ "dt = datetime.datetime.now().strftime(\"%Y%m%d-%H%M%S\")\n",
+ "log_dir = \"logs/my_board/\" + dt\n",
+ "tc = tf.keras.callbacks.TensorBoard(log_dir=log_dir, histogram_freq=1)\n",
+ "es = keras.callbacks.EarlyStopping(monitor='val_loss', mode='min', verbose=1, patience=4)\n",
+ "mc = keras.callbacks.ModelCheckpoint('/content/drive/My Drive/Colab Notebooks/Meditact/model/lstm_20571_' + dt + '.h5', monitor='val_accuracy', mode='max', verbose=1, save_best_only=True)\n",
+ "\n",
+ "model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['accuracy'])\n",
+ "model.summary()"
+ ],
+ "execution_count": 14,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "text": [
+ "Model: \"functional_1\"\n",
+ "__________________________________________________________________________________________________\n",
+ "Layer (type) Output Shape Param # Connected to \n",
+ "==================================================================================================\n",
+ "input_1 (InputLayer) [(None, 10)] 0 \n",
+ "__________________________________________________________________________________________________\n",
+ "embedding (Embedding) (None, 10, 1024) 8192000 input_1[0][0] \n",
+ "__________________________________________________________________________________________________\n",
+ "bidirectional (Bidirectional) (None, 10, 1024) 6295552 embedding[0][0] \n",
+ "__________________________________________________________________________________________________\n",
+ "bidirectional_1 (Bidirectional) [(None, 10, 1024), ( 6295552 bidirectional[0][0] \n",
+ "__________________________________________________________________________________________________\n",
+ "concatenate (Concatenate) (None, 1024) 0 bidirectional_1[0][1] \n",
+ " bidirectional_1[0][3] \n",
+ "__________________________________________________________________________________________________\n",
+ "bahdanau_attention (BahdanauAtt ((None, 1024), (None 525057 bidirectional_1[0][0] \n",
+ " concatenate[0][0] \n",
+ "__________________________________________________________________________________________________\n",
+ "dense_3 (Dense) (None, 256) 262400 bahdanau_attention[0][0] \n",
+ "__________________________________________________________________________________________________\n",
+ "dropout (Dropout) (None, 256) 0 dense_3[0][0] \n",
+ "__________________________________________________________________________________________________\n",
+ "dense_4 (Dense) (None, 64) 16448 dropout[0][0] \n",
+ "__________________________________________________________________________________________________\n",
+ "dropout_1 (Dropout) (None, 64) 0 dense_4[0][0] \n",
+ "__________________________________________________________________________________________________\n",
+ "dense_5 (Dense) (None, 26) 1690 dropout_1[0][0] \n",
+ "==================================================================================================\n",
+ "Total params: 21,588,699\n",
+ "Trainable params: 21,588,699\n",
+ "Non-trainable params: 0\n",
+ "__________________________________________________________________________________________________\n"
+ ],
+ "name": "stdout"
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "metadata": {
+ "scrolled": true,
+ "id": "1tyjL9G7Zp5G",
+ "outputId": "a82deff5-4951-484d-b018-095300ffe870",
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 1000
+ }
+ },
+ "source": [
+ "history = model.fit(padded_x_train, y_train,\n",
+ " batch_size=128, epochs=30, \n",
+ " callbacks=[mc, tc],\n",
+ " #class_weight=weight,\n",
+ " validation_data=(padded_x_test, y_test))"
+ ],
+ "execution_count": 15,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "text": [
+ "WARNING:tensorflow:Model failed to serialize as JSON. Ignoring... \n",
+ "Epoch 1/30\n",
+ " 1/128 [..............................] - ETA: 0s - loss: 3.2607 - accuracy: 0.0156WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/summary_ops_v2.py:1277: stop (from tensorflow.python.eager.profiler) is deprecated and will be removed after 2020-07-01.\n",
+ "Instructions for updating:\n",
+ "use `tf.profiler.experimental.stop` instead.\n",
+ "128/128 [==============================] - ETA: 0s - loss: 2.2671 - accuracy: 0.3590\n",
+ "Epoch 00001: val_accuracy improved from -inf to 0.52057, saving model to /content/drive/My Drive/Colab Notebooks/Meditact/model/lstm_20571_20201020-045024.h5\n",
+ "128/128 [==============================] - 18s 144ms/step - loss: 2.2671 - accuracy: 0.3590 - val_loss: 1.6580 - val_accuracy: 0.5206\n",
+ "Epoch 2/30\n",
+ "128/128 [==============================] - ETA: 0s - loss: 1.4655 - accuracy: 0.5774\n",
+ "Epoch 00002: val_accuracy improved from 0.52057 to 0.63418, saving model to /content/drive/My Drive/Colab Notebooks/Meditact/model/lstm_20571_20201020-045024.h5\n",
+ "128/128 [==============================] - 17s 131ms/step - loss: 1.4655 - accuracy: 0.5774 - val_loss: 1.3064 - val_accuracy: 0.6342\n",
+ "Epoch 3/30\n",
+ "128/128 [==============================] - ETA: 0s - loss: 1.0930 - accuracy: 0.6996\n",
+ "Epoch 00003: val_accuracy improved from 0.63418 to 0.68487, saving model to /content/drive/My Drive/Colab Notebooks/Meditact/model/lstm_20571_20201020-045024.h5\n",
+ "128/128 [==============================] - 17s 131ms/step - loss: 1.0930 - accuracy: 0.6996 - val_loss: 1.1670 - val_accuracy: 0.6849\n",
+ "Epoch 4/30\n",
+ "128/128 [==============================] - ETA: 0s - loss: 0.8743 - accuracy: 0.7634\n",
+ "Epoch 00004: val_accuracy improved from 0.68487 to 0.70299, saving model to /content/drive/My Drive/Colab Notebooks/Meditact/model/lstm_20571_20201020-045024.h5\n",
+ "128/128 [==============================] - 17s 131ms/step - loss: 0.8743 - accuracy: 0.7634 - val_loss: 1.1791 - val_accuracy: 0.7030\n",
+ "Epoch 5/30\n",
+ "128/128 [==============================] - ETA: 0s - loss: 0.7169 - accuracy: 0.8099\n",
+ "Epoch 00005: val_accuracy improved from 0.70299 to 0.71131, saving model to /content/drive/My Drive/Colab Notebooks/Meditact/model/lstm_20571_20201020-045024.h5\n",
+ "128/128 [==============================] - 17s 131ms/step - loss: 0.7169 - accuracy: 0.8099 - val_loss: 1.1834 - val_accuracy: 0.7113\n",
+ "Epoch 6/30\n",
+ "128/128 [==============================] - ETA: 0s - loss: 0.6044 - accuracy: 0.8359\n",
+ "Epoch 00006: val_accuracy improved from 0.71131 to 0.71303, saving model to /content/drive/My Drive/Colab Notebooks/Meditact/model/lstm_20571_20201020-045024.h5\n",
+ "128/128 [==============================] - 17s 132ms/step - loss: 0.6044 - accuracy: 0.8359 - val_loss: 1.1891 - val_accuracy: 0.7130\n",
+ "Epoch 7/30\n",
+ "128/128 [==============================] - ETA: 0s - loss: 0.5311 - accuracy: 0.8554\n",
+ "Epoch 00007: val_accuracy improved from 0.71303 to 0.71719, saving model to /content/drive/My Drive/Colab Notebooks/Meditact/model/lstm_20571_20201020-045024.h5\n",
+ "128/128 [==============================] - 17s 132ms/step - loss: 0.5311 - accuracy: 0.8554 - val_loss: 1.2312 - val_accuracy: 0.7172\n",
+ "Epoch 8/30\n",
+ "128/128 [==============================] - ETA: 0s - loss: 0.4742 - accuracy: 0.8677\n",
+ "Epoch 00008: val_accuracy did not improve from 0.71719\n",
+ "128/128 [==============================] - 17s 132ms/step - loss: 0.4742 - accuracy: 0.8677 - val_loss: 1.2736 - val_accuracy: 0.7079\n",
+ "Epoch 9/30\n",
+ "128/128 [==============================] - ETA: 0s - loss: 0.4197 - accuracy: 0.8826\n",
+ "Epoch 00009: val_accuracy did not improve from 0.71719\n",
+ "128/128 [==============================] - 17s 131ms/step - loss: 0.4197 - accuracy: 0.8826 - val_loss: 1.4095 - val_accuracy: 0.7076\n",
+ "Epoch 10/30\n",
+ "128/128 [==============================] - ETA: 0s - loss: 0.3816 - accuracy: 0.8924\n",
+ "Epoch 00010: val_accuracy did not improve from 0.71719\n",
+ "128/128 [==============================] - 17s 131ms/step - loss: 0.3816 - accuracy: 0.8924 - val_loss: 1.4741 - val_accuracy: 0.7111\n",
+ "Epoch 11/30\n",
+ "128/128 [==============================] - ETA: 0s - loss: 0.3451 - accuracy: 0.8983\n",
+ "Epoch 00011: val_accuracy did not improve from 0.71719\n",
+ "128/128 [==============================] - 17s 132ms/step - loss: 0.3451 - accuracy: 0.8983 - val_loss: 1.6000 - val_accuracy: 0.7059\n",
+ "Epoch 12/30\n",
+ "128/128 [==============================] - ETA: 0s - loss: 0.3264 - accuracy: 0.9046\n",
+ "Epoch 00012: val_accuracy did not improve from 0.71719\n",
+ "128/128 [==============================] - 17s 132ms/step - loss: 0.3264 - accuracy: 0.9046 - val_loss: 1.5829 - val_accuracy: 0.7123\n",
+ "Epoch 13/30\n",
+ " 91/128 [====================>.........] - ETA: 4s - loss: 0.2891 - accuracy: 0.9155"
+ ],
+ "name": "stdout"
+ },
+ {
+ "output_type": "error",
+ "ename": "KeyboardInterrupt",
+ "evalue": "ignored",
+ "traceback": [
+ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
+ "\u001b[0;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)",
+ "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0mcallbacks\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mmc\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtc\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0;31m#class_weight=weight,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 5\u001b[0;31m validation_data=(padded_x_test, y_test))\n\u001b[0m",
+ "\u001b[0;32m/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/training.py\u001b[0m in \u001b[0;36m_method_wrapper\u001b[0;34m(self, *args, **kwargs)\u001b[0m\n\u001b[1;32m 106\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0m_method_wrapper\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 107\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_in_multi_worker_mode\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0;31m# pylint: disable=protected-access\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 108\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mmethod\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 109\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 110\u001b[0m \u001b[0;31m# Running inside `run_distribute_coordinator` already.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
+ "\u001b[0;32m/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/training.py\u001b[0m in \u001b[0;36mfit\u001b[0;34m(self, x, y, batch_size, epochs, verbose, callbacks, validation_split, validation_data, shuffle, class_weight, sample_weight, initial_epoch, steps_per_epoch, validation_steps, validation_batch_size, validation_freq, max_queue_size, workers, use_multiprocessing)\u001b[0m\n\u001b[1;32m 1096\u001b[0m batch_size=batch_size):\n\u001b[1;32m 1097\u001b[0m \u001b[0mcallbacks\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mon_train_batch_begin\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mstep\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1098\u001b[0;31m \u001b[0mtmp_logs\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mtrain_function\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0miterator\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1099\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mdata_handler\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mshould_sync\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1100\u001b[0m \u001b[0mcontext\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0masync_wait\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
+ "\u001b[0;32m/usr/local/lib/python3.6/dist-packages/tensorflow/python/eager/def_function.py\u001b[0m in \u001b[0;36m__call__\u001b[0;34m(self, *args, **kwds)\u001b[0m\n\u001b[1;32m 778\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 779\u001b[0m \u001b[0mcompiler\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m\"nonXla\"\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 780\u001b[0;31m \u001b[0mresult\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_call\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwds\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 781\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 782\u001b[0m \u001b[0mnew_tracing_count\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_get_tracing_count\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
+ "\u001b[0;32m/usr/local/lib/python3.6/dist-packages/tensorflow/python/eager/def_function.py\u001b[0m in \u001b[0;36m_call\u001b[0;34m(self, *args, **kwds)\u001b[0m\n\u001b[1;32m 805\u001b[0m \u001b[0;31m# In this case we have created variables on the first call, so we run the\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 806\u001b[0m \u001b[0;31m# defunned version which is guaranteed to never create variables.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 807\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_stateless_fn\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwds\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;31m# pylint: disable=not-callable\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 808\u001b[0m \u001b[0;32melif\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_stateful_fn\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 809\u001b[0m \u001b[0;31m# Release the lock early so that multiple threads can perform the call\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
+ "\u001b[0;32m/usr/local/lib/python3.6/dist-packages/tensorflow/python/eager/function.py\u001b[0m in \u001b[0;36m__call__\u001b[0;34m(self, *args, **kwargs)\u001b[0m\n\u001b[1;32m 2827\u001b[0m \u001b[0;32mwith\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_lock\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2828\u001b[0m \u001b[0mgraph_function\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mkwargs\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_maybe_define_function\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 2829\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mgraph_function\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_filtered_call\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;31m# pylint: disable=protected-access\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2830\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2831\u001b[0m \u001b[0;34m@\u001b[0m\u001b[0mproperty\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
+ "\u001b[0;32m/usr/local/lib/python3.6/dist-packages/tensorflow/python/eager/function.py\u001b[0m in \u001b[0;36m_filtered_call\u001b[0;34m(self, args, kwargs, cancellation_manager)\u001b[0m\n\u001b[1;32m 1846\u001b[0m resource_variable_ops.BaseResourceVariable))],\n\u001b[1;32m 1847\u001b[0m \u001b[0mcaptured_inputs\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcaptured_inputs\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1848\u001b[0;31m cancellation_manager=cancellation_manager)\n\u001b[0m\u001b[1;32m 1849\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1850\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0m_call_flat\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mcaptured_inputs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mcancellation_manager\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
+ "\u001b[0;32m/usr/local/lib/python3.6/dist-packages/tensorflow/python/eager/function.py\u001b[0m in \u001b[0;36m_call_flat\u001b[0;34m(self, args, captured_inputs, cancellation_manager)\u001b[0m\n\u001b[1;32m 1922\u001b[0m \u001b[0;31m# No tape is watching; skip to running the function.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1923\u001b[0m return self._build_call_outputs(self._inference_function.call(\n\u001b[0;32m-> 1924\u001b[0;31m ctx, args, cancellation_manager=cancellation_manager))\n\u001b[0m\u001b[1;32m 1925\u001b[0m forward_backward = self._select_forward_and_backward_functions(\n\u001b[1;32m 1926\u001b[0m \u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
+ "\u001b[0;32m/usr/local/lib/python3.6/dist-packages/tensorflow/python/eager/function.py\u001b[0m in \u001b[0;36mcall\u001b[0;34m(self, ctx, args, cancellation_manager)\u001b[0m\n\u001b[1;32m 548\u001b[0m \u001b[0minputs\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 549\u001b[0m \u001b[0mattrs\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mattrs\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 550\u001b[0;31m ctx=ctx)\n\u001b[0m\u001b[1;32m 551\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 552\u001b[0m outputs = execute.execute_with_cancellation(\n",
+ "\u001b[0;32m/usr/local/lib/python3.6/dist-packages/tensorflow/python/eager/execute.py\u001b[0m in \u001b[0;36mquick_execute\u001b[0;34m(op_name, num_outputs, inputs, attrs, ctx, name)\u001b[0m\n\u001b[1;32m 58\u001b[0m \u001b[0mctx\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mensure_initialized\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 59\u001b[0m tensors = pywrap_tfe.TFE_Py_Execute(ctx._handle, device_name, op_name,\n\u001b[0;32m---> 60\u001b[0;31m inputs, attrs, num_outputs)\n\u001b[0m\u001b[1;32m 61\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mcore\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_NotOkStatusException\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0me\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 62\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mname\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
+ "\u001b[0;31mKeyboardInterrupt\u001b[0m: "
+ ]
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "metadata": {
+ "id": "g_KkDWI9mm8v"
+ },
+ "source": [
+ "from keras.models import load_model\n",
+ "model = load_model('/content/drive/My Drive/Colab Notebooks/Meditact/model/lstm_20571_20201016-132514.h5')\n",
+ "\n"
+ ],
+ "execution_count": null,
+ "outputs": []
+ },
+ {
+ "cell_type": "code",
+ "metadata": {
+ "id": "EkMbzfvFrNLu"
+ },
+ "source": [
+ "class_to_label = {'DERM': 0, 'GS': 1, 'IP': 2, 'GI':3, 'OPH':4,\n",
+ " 'NR': 5, 'ENT': 6, 'PSY': 7, 'HEON': 8, 'RHEU': 9,\n",
+ " 'REHM': 10, 'NS': 11, 'AN': 12, 'DENT': 13, 'PS': 14,\n",
+ " 'CS': 15, 'INFC': 16, 'OS': 17,\n",
+ " 'EMR': 18, 'ENDO': 19, 'CA': 20, 'KTM': 21, 'OBGY': 22,\n",
+ " 'URO': 23, 'ALL': 24, 'NPH': 25}\n",
+ "label_to_class = {value:key for key, value in class_to_label.items()}\n"
+ ],
+ "execution_count": 16,
+ "outputs": []
+ },
+ {
+ "cell_type": "code",
+ "metadata": {
+ "id": "iG1Hs-sTXAbj",
+ "outputId": "58353c07-dd9c-493b-e722-a3216e2ff144",
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 598
+ }
+ },
+ "source": [
+ "!pip install konlpy"
+ ],
+ "execution_count": 20,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "text": [
+ "Collecting konlpy\n",
+ "\u001b[?25l Downloading https://files.pythonhosted.org/packages/85/0e/f385566fec837c0b83f216b2da65db9997b35dd675e107752005b7d392b1/konlpy-0.5.2-py2.py3-none-any.whl (19.4MB)\n",
+ "\u001b[K |████████████████████████████████| 19.4MB 161kB/s \n",
+ "\u001b[?25hRequirement already satisfied: lxml>=4.1.0 in /usr/local/lib/python3.6/dist-packages (from konlpy) (4.2.6)\n",
+ "Collecting beautifulsoup4==4.6.0\n",
+ "\u001b[?25l Downloading https://files.pythonhosted.org/packages/9e/d4/10f46e5cfac773e22707237bfcd51bbffeaf0a576b0a847ec7ab15bd7ace/beautifulsoup4-4.6.0-py3-none-any.whl (86kB)\n",
+ "\u001b[K |████████████████████████████████| 92kB 12.7MB/s \n",
+ "\u001b[?25hRequirement already satisfied: numpy>=1.6 in /usr/local/lib/python3.6/dist-packages (from konlpy) (1.18.5)\n",
+ "Collecting colorama\n",
+ " Downloading https://files.pythonhosted.org/packages/44/98/5b86278fbbf250d239ae0ecb724f8572af1c91f4a11edf4d36a206189440/colorama-0.4.4-py2.py3-none-any.whl\n",
+ "Collecting JPype1>=0.7.0\n",
+ "\u001b[?25l Downloading https://files.pythonhosted.org/packages/8b/f7/a368401e630f0e390dd0e62c39fb928e5b23741b53c2360ee7d376660927/JPype1-1.0.2-cp36-cp36m-manylinux2010_x86_64.whl (3.8MB)\n",
+ "\u001b[K |████████████████████████████████| 3.8MB 57.8MB/s \n",
+ "\u001b[?25hCollecting tweepy>=3.7.0\n",
+ " Downloading https://files.pythonhosted.org/packages/bb/7c/99d51f80f3b77b107ebae2634108717362c059a41384a1810d13e2429a81/tweepy-3.9.0-py2.py3-none-any.whl\n",
+ "Requirement already satisfied: typing-extensions; python_version < \"3.8\" in /usr/local/lib/python3.6/dist-packages (from JPype1>=0.7.0->konlpy) (3.7.4.3)\n",
+ "Requirement already satisfied: requests-oauthlib>=0.7.0 in /usr/local/lib/python3.6/dist-packages (from tweepy>=3.7.0->konlpy) (1.3.0)\n",
+ "Requirement already satisfied: requests[socks]>=2.11.1 in /usr/local/lib/python3.6/dist-packages (from tweepy>=3.7.0->konlpy) (2.23.0)\n",
+ "Requirement already satisfied: six>=1.10.0 in /usr/local/lib/python3.6/dist-packages (from tweepy>=3.7.0->konlpy) (1.15.0)\n",
+ "Requirement already satisfied: oauthlib>=3.0.0 in /usr/local/lib/python3.6/dist-packages (from requests-oauthlib>=0.7.0->tweepy>=3.7.0->konlpy) (3.1.0)\n",
+ "Requirement already satisfied: idna<3,>=2.5 in /usr/local/lib/python3.6/dist-packages (from requests[socks]>=2.11.1->tweepy>=3.7.0->konlpy) (2.10)\n",
+ "Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.6/dist-packages (from requests[socks]>=2.11.1->tweepy>=3.7.0->konlpy) (2020.6.20)\n",
+ "Requirement already satisfied: chardet<4,>=3.0.2 in /usr/local/lib/python3.6/dist-packages (from requests[socks]>=2.11.1->tweepy>=3.7.0->konlpy) (3.0.4)\n",
+ "Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /usr/local/lib/python3.6/dist-packages (from requests[socks]>=2.11.1->tweepy>=3.7.0->konlpy) (1.24.3)\n",
+ "Requirement already satisfied: PySocks!=1.5.7,>=1.5.6; extra == \"socks\" in /usr/local/lib/python3.6/dist-packages (from requests[socks]>=2.11.1->tweepy>=3.7.0->konlpy) (1.7.1)\n",
+ "Installing collected packages: beautifulsoup4, colorama, JPype1, tweepy, konlpy\n",
+ " Found existing installation: beautifulsoup4 4.6.3\n",
+ " Uninstalling beautifulsoup4-4.6.3:\n",
+ " Successfully uninstalled beautifulsoup4-4.6.3\n",
+ " Found existing installation: tweepy 3.6.0\n",
+ " Uninstalling tweepy-3.6.0:\n",
+ " Successfully uninstalled tweepy-3.6.0\n",
+ "Successfully installed JPype1-1.0.2 beautifulsoup4-4.6.0 colorama-0.4.4 konlpy-0.5.2 tweepy-3.9.0\n"
+ ],
+ "name": "stdout"
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "metadata": {
+ "id": "g_Xc_odzZp5L"
+ },
+ "source": [
+ "from konlpy.tag import Okt\n",
+ "def preprocess_sentence(sentence):\n",
+ " twitter = Okt()\n",
+ " nouns = twitter.nouns(sentence)\n",
+ " stopwords = ['질문', '문의', '관련', '그대로', '계속', '답변', '선생님', '관련문의',\n",
+ " '한지', '자주', '좀', '쪽', '자꾸', '요즘', '몇개', '무조건', '하나요',\n",
+ " '안해','요', '경우', '최근', '및', '몇', '달', '일반', '전날', '저번',\n",
+ " '말', '일어나지', '며칠', '먹기', '지난번', '글', '때문', '너', '무',\n",
+ " '오늘', '시', '잔', '뒤', '지속', '막', '것', '이건', '뭔가', '다시', '그',\n",
+ " '무슨', '안', '난', '도', '기', '후', '거리', '이', '뭘', '저', '뭐', '답젼',\n",
+ " '평생', '회복', '반', '감사', '의사', '보험', '학생', '제발', '살짝',\n",
+ " '느낌', '제', '대해','갑자기','문제', '전','정도', '왜', '거', '가요',\n",
+ " '의심', '어제', '추천', '를', '지금', '무엇', '내일', '관해', '리', '세',\n",
+ " '로', '목적', '그냥', '거의', '고민', '다음', '이틀', '항상', '뭐', '때',\n",
+ " '요', '가끔', '이후', '혹시', ]\n",
+ " for word in nouns:\n",
+ " if word in stopwords:\n",
+ " while word in nouns:\n",
+ " nouns.remove(word)\n",
+ " return nouns\n",
+ "\n",
+ "def predict(sen):\n",
+ " global model\n",
+ " test = preprocess_sentence(sen)\n",
+ " test_batch = []\n",
+ " test_batch.append(test)\n",
+ " pre_test = t.texts_to_sequences(test_batch)\n",
+ " padded_pre_test = tf.keras.preprocessing.sequence.pad_sequences(pre_test, truncating=trunc_type, padding=padding_type, maxlen=sequence_length)\n",
+ "\n",
+ " result = model.predict(padded_pre_test)\n",
+ " sorted = result.argsort()\n",
+ " sp = result.argmax()\n",
+ " val = result.max()\n",
+ " base = '{0}확률로 {1}과를 방문하셔야 합니다'\n",
+ " return base.format(val, label_to_class[sp])"
+ ],
+ "execution_count": 21,
+ "outputs": []
+ },
+ {
+ "cell_type": "code",
+ "metadata": {
+ "id": "P3CRIDapwRuf",
+ "outputId": "27bb3907-50d7-4c13-f961-690b465f2462",
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 35
+ }
+ },
+ "source": [
+ "sentence = \"잠이 너무 안와서 다음날 몽롱해요\"\n",
+ "predict(sentence)"
+ ],
+ "execution_count": 22,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "application/vnd.google.colaboratory.intrinsic+json": {
+ "type": "string"
+ },
+ "text/plain": [
+ "'0.9999998807907104확률로 PSY과를 방문하셔야 합니다'"
+ ]
+ },
+ "metadata": {
+ "tags": []
+ },
+ "execution_count": 22
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "metadata": {
+ "id": "DIRe-9MqnkML",
+ "outputId": "e23abbc1-7304-44f7-9e94-85b93e659258",
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 35
+ }
+ },
+ "source": [
+ "sentence = \"통풍으로 엄지발가락이 부었어요\"\n",
+ "predict(sentence)"
+ ],
+ "execution_count": 23,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "application/vnd.google.colaboratory.intrinsic+json": {
+ "type": "string"
+ },
+ "text/plain": [
+ "'0.8111918568611145확률로 OS과를 방문하셔야 합니다'"
+ ]
+ },
+ "metadata": {
+ "tags": []
+ },
+ "execution_count": 23
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "metadata": {
+ "id": "12KQffewyD-R",
+ "outputId": "e94b1b43-564e-4d44-b00c-55555da35a86",
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 35
+ }
+ },
+ "source": [
+ "sentence = \"오래된 이명과 비염이 있어요\"\n",
+ "predict(sentence)"
+ ],
+ "execution_count": 24,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "application/vnd.google.colaboratory.intrinsic+json": {
+ "type": "string"
+ },
+ "text/plain": [
+ "'0.9991840720176697확률로 ENT과를 방문하셔야 합니다'"
+ ]
+ },
+ "metadata": {
+ "tags": []
+ },
+ "execution_count": 24
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "metadata": {
+ "id": "nuyvWhbcyJZY",
+ "outputId": "eaefa362-4764-4170-acb1-be60882026c1",
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 35
+ }
+ },
+ "source": [
+ "sentence = \"뇌경색 이후에 어떤 운동을 하는게 좋은가요\"\n",
+ "predict(sentence)"
+ ],
+ "execution_count": 25,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "application/vnd.google.colaboratory.intrinsic+json": {
+ "type": "string"
+ },
+ "text/plain": [
+ "'0.9163525104522705확률로 REHM과를 방문하셔야 합니다'"
+ ]
+ },
+ "metadata": {
+ "tags": []
+ },
+ "execution_count": 25
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "metadata": {
+ "id": "RqePT8PbyMvD",
+ "outputId": "02851002-3f54-49a2-cc43-2149b0db20da",
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 35
+ }
+ },
+ "source": [
+ "sentence = \"항문 주변이 따가워요\"\n",
+ "predict(sentence)"
+ ],
+ "execution_count": 26,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "application/vnd.google.colaboratory.intrinsic+json": {
+ "type": "string"
+ },
+ "text/plain": [
+ "'0.976958692073822확률로 GS과를 방문하셔야 합니다'"
+ ]
+ },
+ "metadata": {
+ "tags": []
+ },
+ "execution_count": 26
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "metadata": {
+ "id": "8mOcGymxyP87"
+ },
+ "source": [
+ ""
+ ],
+ "execution_count": null,
+ "outputs": []
+ }
+ ]
+}
\ No newline at end of file