전체 인덱싱+뮤지컬.ipynb
171 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"5699\n",
"9823\n",
"14020\n",
"2727\n",
"1498\n",
"1464\n"
]
}
],
"source": [
"import pandas as pd\n",
"from nltk.corpus import stopwords\n",
"from nltk.tokenize import word_tokenize\n",
"import re\n",
"\n",
"\"\"\"\n",
"thriller_plot = pd.read_csv('/Users/yangyoonji/Documents/2020-1/2020-dataCapstone/data/moviedata/moviePlot/thrillerPlot.csv')\n",
"drama_plot = pd.read_csv('/Users/yangyoonji/Documents/2020-1/2020-dataCapstone/data/moviedata/moviePlot/dramaPlot.csv')\n",
"fantasy_plot = pd.read_csv('/Users/yangyoonji/Documents/2020-1/2020-dataCapstone/data/moviedata/moviePlot/fantasyPlot.csv')\n",
"history_plot = pd.read_csv('/Users/yangyoonji/Documents/2020-1/2020-dataCapstone/data/moviedata/moviePlot/historyPlot.csv')\n",
"social_plot = pd.read_csv('/Users/yangyoonji/Documents/2020-1/2020-dataCapstone/data/moviedata/moviePlot/socialPlot.csv')\n",
"romance_plot = pd.read_csv('/Users/yangyoonji/Documents/2020-1/2020-dataCapstone/data/moviedata/moviePlot/romancePlot.csv')\n",
"musical_plot = pd.read_csv('/Users/yangyoonji/Documents/2020-1/2020-dataCapstone/data/musicalData/broadMusicalPlot.csv',encoding='cp949')\n",
"\n",
"# /Users/김서영/Desktop/datacap/data/moviedata/moviePlot/romancePlot.csv\n",
"\"\"\"\n",
"romance_plot = pd.read_csv('/Users/김서영/Desktop/datacap/data/moviedata/moviePlot/romancePlot.csv')\n",
"thriller_plot = pd.read_csv('/Users/김서영/Desktop/datacap/data/moviedata/moviePlot/thrillerPlot.csv')\n",
"drama_plot = pd.read_csv('/Users/김서영/Desktop/datacap/data/moviedata/moviePlot/dramaPlot.csv')\n",
"fantasy_plot = pd.read_csv('/Users/김서영/Desktop/datacap/data/moviedata/moviePlot/fantasyPlot.csv')\n",
"history_plot = pd.read_csv('/Users/김서영/Desktop/datacap/data/moviedata/moviePlot/historyPlot.csv')\n",
"social_plot = pd.read_csv('/Users/김서영/Desktop/datacap/data/moviedata/moviePlot/socialPlot.csv')\n",
"\n",
"musical_plot = pd.read_csv('/Users/김서영/Desktop/datacap/data/musicalData/broadMusicalPlot.csv',encoding='cp949')\n",
"\n",
"\n",
"print(len(romance_plot)) #5699 ==> train 2500 test 2500\n",
"print(len(thriller_plot)) #9823 ==> train 2500 test 2500\n",
"print(len(drama_plot))\n",
"print(len(fantasy_plot))\n",
"print(len(history_plot))\n",
"print(len(social_plot))\n",
"\n",
"train_data_size = 1463\n",
"test_data_size = 1463\n",
"\n",
"#전처리(1) 전부 소문자로 변환\n",
"\n",
"\n",
"#romance_plot.줄거리 = romance_plot.줄거리.str.lower()\n",
"#thriller_plot.줄거리 = thriller_plot.줄거리.str.lower()\n",
"\n",
"#전처리(1-1) 데이터 csv 파일로 옮기기\n",
"#romance_plot 2899개 train_data로 to_csv || 2800개 test_data로 to_csv\n",
"#thriller_plot 2899개 train_data로 to_csv || 2800개 test_data로 to_csv\n"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"RM = [[] for _ in range(5699)]\n",
"for i in range(5699):\n",
" RM[i].append(''.join(romance_plot.줄거리[i]))\n",
" \n",
"TH = [[] for _ in range(9823)]\n",
"for i in range(9823):\n",
" TH[i].append(''.join(thriller_plot.줄거리[i]))\n",
"\n",
"FN = [[] for _ in range(2727)]\n",
"for i in range(2727):\n",
" FN[i].append(''.join(fantasy_plot.줄거리[i]))\n",
" \n",
"HS = [[] for _ in range(1498)]\n",
"for i in range(1498):\n",
" HS[i].append(''.join(history_plot.줄거리[i]))\n",
" \n",
"SC = [[] for _ in range(1464)]\n",
"for i in range(1464):\n",
" SC[i].append(''.join(social_plot.줄거리[i]))\n",
"\n",
"DR = [[] for _ in range(14019)]\n",
"for i in range(14019):\n",
" DR[i].append(''.join(drama_plot.줄거리[i]))\n",
" \n",
"Mu = [[] for _ in range(307)]\n",
"for i in range(307):\n",
" Mu[i].append(''.join(musical_plot.muplot[i]))\n",
" "
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"allplot = RM+TH+FN+HS+SC+DR #모든 드라마 줄거리"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"35230\n",
"307\n"
]
}
],
"source": [
"print(len(allplot))\n",
"print(len(musical_plot))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 모든 장르 줄거리 "
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"100%|███████████████████████████████████████████████████████████████████████████| 35230/35230 [02:16<00:00, 257.99it/s]\n"
]
}
],
"source": [
"# 토큰화+전처리(3) 전체 불용어 처리\n",
"# 전체 플롯\n",
"from tqdm import tqdm\n",
"all_vocab = {} \n",
"all_sentences = []\n",
"stop_words = set(stopwords.words('english'))\n",
"\n",
"for i in tqdm(allplot):\n",
" all_sentences = word_tokenize(str(i)) # 단어 토큰화를 수행합니다.\n",
" result = []\n",
" for word in all_sentences: \n",
" word = word.lower() # 모든 단어를 소문자화하여 단어의 개수를 줄입니다.\n",
" if word not in stop_words: # 단어 토큰화 된 결과에 대해서 불용어를 제거합니다.\n",
" if len(word) > 2: # 단어 길이가 2이하인 경우에 대하여 추가로 단어를 제거합니다.\n",
" result.append(word)\n",
" if word not in all_vocab:\n",
" all_vocab[word] = 0 \n",
" all_vocab[word] += 1\n",
" all_sentences.append(result) "
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"all_vocab_sorted = sorted(all_vocab.items(), key = lambda x:x[1], reverse = True)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
"#전처리(4) 인덱스 부여\n",
"all_word_to_index = {}\n",
"i=0\n",
"for (word, frequency) in all_vocab_sorted :\n",
" if frequency > 1 : # 정제(Cleaning) 챕터에서 언급했듯이 빈도수가 적은 단어는 제외한다.\n",
" i=i+1\n",
" all_word_to_index[word] = i\n",
"#print(all_word_to_index)\n",
"\n",
"vocab_size = 15000 #상위 15000개 단어만 사용\n",
"words_frequency = [w for w,c in all_word_to_index.items() if c >= vocab_size + 1] # 인덱스가 15000 초과인 단어 제거\n",
"for w in words_frequency:\n",
" del all_word_to_index[w] # 해당 단어에 대한 인덱스 정보를 삭제\n",
"\n",
" \n",
"all_word_to_index['OOV'] = len(all_word_to_index) + 1"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 로맨스"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"100%|█████████████████████████████████████████████████████████████████████████████| 5699/5699 [00:19<00:00, 288.55it/s]\n"
]
}
],
"source": [
"# 토큰화+전처리(3) 불용어 처리\n",
"# 로맨스 플롯\n",
"\n",
"vocab_r = {} \n",
"RMsentences = []\n",
"RMstop_words = set(stopwords.words('english'))\n",
"\n",
"for i in tqdm(RM):\n",
" RMsentence = word_tokenize(str(i)) # 단어 토큰화를 수행합니다.\n",
" result = []\n",
"\n",
" for word in RMsentence: \n",
" word = word.lower() # 모든 단어를 소문자화하여 단어의 개수를 줄입니다.\n",
" if word not in RMstop_words: # 단어 토큰화 된 결과에 대해서 불용어를 제거합니다.\n",
" if len(word) > 2: # 단어 길이가 2이하인 경우에 대하여 추가로 단어를 제거합니다.\n",
" result.append(word)\n",
" if word not in vocab_r:\n",
" vocab_r[word] = 0 \n",
" vocab_r[word] += 1\n",
" RMsentences.append(result) \n",
"\n",
"R_encoded = []\n",
"for s in RMsentences:\n",
" temp = []\n",
" for w in s:\n",
" try:\n",
" temp.append(all_word_to_index[w])\n",
" except KeyError:\n",
" temp.append(all_word_to_index['OOV'])\n",
" R_encoded.append(temp)\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 스릴러"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {
"scrolled": false
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"100%|█████████████████████████████████████████████████████████████████████████████| 9823/9823 [00:44<00:00, 221.65it/s]\n"
]
}
],
"source": [
"# 토큰화+전처리(3) 불용어 처리\n",
"# 스릴러 플롯\n",
"\n",
"vocab_th = {} \n",
"THsentences = []\n",
"THstop_words = set(stopwords.words('english'))\n",
"\n",
"for i in tqdm(TH):\n",
" \n",
" THsentence = word_tokenize(str(i)) # 단어 토큰화를 수행합니다.\n",
" result = []\n",
"\n",
" for word in THsentence: \n",
" word = word.lower() # 모든 단어를 소문자화하여 단어의 개수를 줄입니다.\n",
" if word not in THstop_words: # 단어 토큰화 된 결과에 대해서 불용어를 제거합니다.\n",
" if len(word) > 2: # 단어 길이가 2이하인 경우에 대하여 추가로 단어를 제거합니다.\n",
" result.append(word)\n",
" if word not in vocab_th:\n",
" vocab_th[word] = 0 \n",
" vocab_th[word] += 1\n",
" THsentences.append(result) \n",
"\n",
"TH_encoded = []\n",
"for s in THsentences:\n",
" temp = []\n",
" for w in s:\n",
" try:\n",
" temp.append(all_word_to_index[w])\n",
" except KeyError:\n",
" temp.append(all_word_to_index['OOV'])\n",
" TH_encoded.append(temp)\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 역사"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"100%|█████████████████████████████████████████████████████████████████████████████| 1498/1498 [00:05<00:00, 281.17it/s]\n"
]
}
],
"source": [
"vocab_HS = {} \n",
"HSsentences = []\n",
"HSstop_words = set(stopwords.words('english'))\n",
"\n",
"for i in tqdm(HS):\n",
" \n",
" HSsentence = word_tokenize(str(i)) # 단어 토큰화를 수행합니다.\n",
" result = []\n",
"\n",
" for word in HSsentence: \n",
" word = word.lower() # 모든 단어를 소문자화하여 단어의 개수를 줄입니다.\n",
" if word not in HSstop_words: # 단어 토큰화 된 결과에 대해서 불용어를 제거합니다.\n",
" if len(word) > 2: # 단어 길이가 2이하인 경우에 대하여 추가로 단어를 제거합니다.\n",
" result.append(word)\n",
" if word not in vocab_HS:\n",
" vocab_HS[word] = 0 \n",
" vocab_HS[word] += 1\n",
" HSsentences.append(result) \n",
"\n",
"HS_encoded = []\n",
"for s in HSsentences:\n",
" temp = []\n",
" for w in s:\n",
" try:\n",
" temp.append(all_word_to_index[w])\n",
" except KeyError:\n",
" temp.append(all_word_to_index['OOV'])\n",
" HS_encoded.append(temp)\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 드라마"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"100%|███████████████████████████████████████████████████████████████████████████| 14019/14019 [00:44<00:00, 316.67it/s]\n"
]
}
],
"source": [
"vocab_DR = {} \n",
"DRsentences = []\n",
"DRstop_words = set(stopwords.words('english'))\n",
"\n",
"for i in tqdm(DR):\n",
" \n",
" DRsentence = word_tokenize(str(i)) # 단어 토큰화를 수행합니다.\n",
" result = []\n",
"\n",
" for word in DRsentence: \n",
" word = word.lower() # 모든 단어를 소문자화하여 단어의 개수를 줄입니다.\n",
" if word not in DRstop_words: # 단어 토큰화 된 결과에 대해서 불용어를 제거합니다.\n",
" if len(word) > 2: # 단어 길이가 2이하인 경우에 대하여 추가로 단어를 제거합니다.\n",
" result.append(word)\n",
" if word not in vocab_DR:\n",
" vocab_DR[word] = 0 \n",
" vocab_DR[word] += 1\n",
" DRsentences.append(result) \n",
"\n",
"DR_encoded = []\n",
"for s in DRsentences:\n",
" temp = []\n",
" for w in s:\n",
" try:\n",
" temp.append(all_word_to_index[w])\n",
" except KeyError:\n",
" temp.append(all_word_to_index['OOV'])\n",
" DR_encoded.append(temp)\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 판타지"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"100%|█████████████████████████████████████████████████████████████████████████████| 2727/2727 [00:12<00:00, 214.44it/s]\n"
]
}
],
"source": [
"vocab_FN = {} \n",
"FNsentences = []\n",
"FNstop_words = set(stopwords.words('english'))\n",
"\n",
"for i in tqdm(FN):\n",
" \n",
" FNsentence = word_tokenize(str(i)) # 단어 토큰화를 수행합니다.\n",
" result = []\n",
"\n",
" for word in FNsentence: \n",
" word = word.lower() # 모든 단어를 소문자화하여 단어의 개수를 줄입니다.\n",
" if word not in FNstop_words: # 단어 토큰화 된 결과에 대해서 불용어를 제거합니다.\n",
" if len(word) > 2: # 단어 길이가 2이하인 경우에 대하여 추가로 단어를 제거합니다.\n",
" result.append(word)\n",
" if word not in vocab_FN:\n",
" vocab_FN[word] = 0 \n",
" vocab_FN[word] += 1\n",
" FNsentences.append(result) \n",
"\n",
"FN_encoded = []\n",
"for s in FNsentences:\n",
" temp = []\n",
" for w in s:\n",
" try:\n",
" temp.append(all_word_to_index[w])\n",
" except KeyError:\n",
" temp.append(all_word_to_index['OOV'])\n",
" FN_encoded.append(temp)\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 사회"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"100%|█████████████████████████████████████████████████████████████████████████████| 1464/1464 [00:05<00:00, 266.80it/s]\n"
]
}
],
"source": [
"vocab_SC = {} \n",
"SCsentences = []\n",
"SCstop_words = set(stopwords.words('english'))\n",
"\n",
"for i in tqdm(SC):\n",
" \n",
" SCsentence = word_tokenize(str(i)) # 단어 토큰화를 수행합니다.\n",
" result = []\n",
"\n",
" for word in SCsentence: \n",
" word = word.lower() # 모든 단어를 소문자화하여 단어의 개수를 줄입니다.\n",
" if word not in SCstop_words: # 단어 토큰화 된 결과에 대해서 불용어를 제거합니다.\n",
" if len(word) > 2: # 단어 길이가 2이하인 경우에 대하여 추가로 단어를 제거합니다.\n",
" result.append(word)\n",
" if word not in vocab_SC:\n",
" vocab_SC[word] = 0 \n",
" vocab_SC[word] += 1\n",
" SCsentences.append(result) \n",
"\n",
"SC_encoded = []\n",
"for s in SCsentences:\n",
" temp = []\n",
" for w in s:\n",
" try:\n",
" temp.append(all_word_to_index[w])\n",
" except KeyError:\n",
" temp.append(all_word_to_index['OOV'])\n",
" SC_encoded.append(temp)\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 뮤지컬"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"100%|██████████████████████████████████████████████████████████████████████████████| 307/307 [00:00<00:00, 1256.35it/s]\n"
]
}
],
"source": [
"# 토큰화+전처리(3) 전체 불용어 처리\n",
"# 전체 플롯\n",
"from tqdm import tqdm\n",
"Mu_vocab = {} \n",
"Mu_sentences = []\n",
"Mu_stop_words = set(stopwords.words('english'))\n",
"\n",
"for i in tqdm(Mu):\n",
" Mu_sentence = word_tokenize(str(i)) # 단어 토큰화를 수행합니다.\n",
" result = []\n",
" \n",
" for word in Mu_sentence: \n",
" word = word.lower() # 모든 단어를 소문자화하여 단어의 개수를 줄입니다.\n",
" if word not in Mu_stop_words: # 단어 토큰화 된 결과에 대해서 불용어를 제거합니다.\n",
" if len(word) > 2: # 단어 길이가 2이하인 경우에 대하여 추가로 단어를 제거합니다.\n",
" result.append(word)\n",
" if word not in Mu_vocab:\n",
" Mu_vocab[word] = 0 \n",
" Mu_vocab[word] += 1\n",
"\n",
" Mu_sentences.append(result) "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"print(Mu_sentences)"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [],
"source": [
"Mu_encoded = []\n",
"for s in Mu_sentences:\n",
" temp = []\n",
" for w in s:\n",
" try:\n",
" temp.append(all_word_to_index[w])\n",
" except KeyError:\n",
" temp.append(all_word_to_index['OOV'])\n",
" Mu_encoded.append(temp)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"print(Mu_encoded)"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [],
"source": [
"#전처리 방법에는 NLTK의 FreqDist, 케라스(Keras) 토크나이저도 사용 가능."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"로맨스 플롯, 스릴러 따로 토큰화 해서 x train에 넣을지... 고민중\n",
"\n",
"이번주 : 전처리 완료, \n",
"이번 달 목표 : 뮤지컬 장르 분류 << 다양한 모델 사용해보기.\n",
"\n",
"6월에 교차검증 및 장르 시각화 설계까지.\n",
"\n",
"다음주 : 2진분류(LSTM) 완료, RNN 분류기 만들어보기"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 학습데이터"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [],
"source": [
"# 영화 줄거리는 X_train에, 장르 정보는 y_train에 저장된다.\n",
"# 테스트용 줄거리 X_test에, 테스트용 줄거리의 장르 정보는 y_test에 저장된다.\n",
"#맞춰서 저장하기. (진행중)\n",
"\n",
"#X_train = train_sc_df.dropna().drop(‘trade_price_idx_value’, axis=1)"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {},
"outputs": [],
"source": [
"X_train = []\n",
"Y_train = [] #0 : romance, 1 : thriller \n",
"for i in range(train_data_size):\n",
" X_train.append(R_encoded[i])\n",
" Y_train.append([1,0])\n",
" X_train.append(TH_encoded[i])\n",
" Y_train.append([0,1])"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"줄거리 최대 길이 : 1974\n",
"줄거리 평균 길이 : 267.093984962406\n"
]
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYUAAAD4CAYAAAAD6PrjAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjMsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+AADFEAAAdIElEQVR4nO3df5DU9Z3n8eeLSYt7ahQUlR+yY3IkhaEuaii1SjbnrBtFsiXkKslJpZTVuSPZEy7WJhYYrko3ualyvY1WZPfYwx1K3DJjvDWWVNQlxHPPoyoa0RDFTFzREDNCgAQWUZQ4zPv++H76azP0DD3TPd3T7etR1dXf/vS3+/ue6Yb3fD+fz/f9U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6rUjwvA1fV6nME5pF187wAbE23BfX63bjMhZmZ5dx9ZGZmOScFMzPLOSmYmVnOScHMzHJOCmZmlnNSMDOznJOCmZnl/j8lGxvkzw55lwAAAABJRU5ErkJggg==\n",
"text/plain": [
"<Figure size 432x288 with 2 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"import matplotlib.pyplot as plt\n",
"%matplotlib inline\n",
"\n",
"len_result = [len(s) for s in X_train]\n",
"print(\"줄거리 최대 길이 : \",max(len_result))\n",
"print(\"줄거리 평균 길이 : \",sum(len_result)/len(len_result))\n",
"\n",
"plt.subplot(1,2,1)\n",
"plt.boxplot(len_result)\n",
"plt.subplot(1,2,2)\n",
"plt.hist(len_result, bins=50)\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 테스트 데이터\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {},
"outputs": [],
"source": [
"X_test = []\n",
"Y_test = [] #0 : romance, 1 : thriller \n",
"M_test = []\n",
"for i in range(test_data_size):\n",
" X_test.append(R_encoded[train_data_size+i])\n",
" Y_test.append([1,0])\n",
" X_test.append(TH_encoded[train_data_size+i])\n",
" Y_test.append([0,1])\n",
"M_test=Mu_encoded"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"줄거리 최대 길이 : 1749\n",
"줄거리 평균 길이 : 197.71394395078605\n"
]
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAX0AAAD4CAYAAAAAczaOAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjMsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+AADFEAAAbkUlEQVR4nO3db3Bc1Znn8e/Psk2ymRgsMIY1sCLBSZm4NoaoGAqUFIbB2GQqTraS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ji2NwLfStvXAz8gd53C5cBTU5DPiO/2qeYDNAIvp/XctD13inK7DfhvRdpenD7X04AL0+fdUOnP3kf6dSIingCOVTsPm7Rav3/0SmBL2t4CfLYg/kDkPAmcIenccr7xKN/tU83nOmBHRByLiOPADmD5FOU2mpXAgxHxTkT8Augh97lX9LN30TerDRO6f3SFBPBDSXvS1BEA8yPiCEBan53i1cr7VPOpdJ43pe6lzfmup1rJzUXfrDZM6P7RFXJlRFwKrADWS/rUGG1rKW8YPZ9K5nkv8GFgCXAE+HaK10JuLvpmNaJmpnGIiMNpfRTYSq77oTffbZPWR1PzauV9qvlULM+I6I2IgYgYBO4n9+9XE7mBi75ZraiJaRwkfUDSB/PbwDJgf8olP+JlDfBw2t4G3JhGzVwOvJHvdplip5rPY8AySXNTd8uyFCu7Yec0Pkfu3y+f2ypJp6X7hC8EfkKlP/upOkPspbIL0Enuv5LvkTtyaK12Tl5O+TO8Hvg5uZEcbVXK4UPkRo/8DHgunwdwJrATOJDWjSkucjePeQl4FmiegpxGfLcnkw/wJ+ROnvYAX5rC3P5Peu9nyBXvcwvat6XcXgRWVOOz9zQMZmYZ4u4dM7MMcdE3M8sQF30zswxx0TczyxAXfTOzDHHRNzPLEBd9M7MM+f8TmXUVrZGt4wAAAABJRU5ErkJggg==\n",
"text/plain": [
"<Figure size 432x288 with 2 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"import matplotlib.pyplot as plt\n",
"%matplotlib inline\n",
"\n",
"len_result = [len(s) for s in X_test]\n",
"print(\"줄거리 최대 길이 : \",max(len_result))\n",
"print(\"줄거리 평균 길이 : \",sum(len_result)/len(len_result))\n",
"\n",
"plt.subplot(1,2,1)\n",
"plt.boxplot(len_result)\n",
"plt.subplot(1,2,2)\n",
"plt.hist(len_result, bins=50)\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## LSTM 분류 \n"
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {},
"outputs": [],
"source": [
"from tensorflow.keras.preprocessing.sequence import pad_sequences\n",
"from tensorflow.keras.models import Sequential\n",
"from tensorflow.keras.layers import Dense, LSTM, Embedding\n",
"from tensorflow.keras.callbacks import EarlyStopping, ModelCheckpoint\n",
"import numpy as np\n",
"\n",
"M_test= np.array(M_test)\n",
"max_len = 230\n",
"X_train = pad_sequences(X_train, maxlen=max_len)\n",
"X_test = pad_sequences(X_test, maxlen=max_len)\n"
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {
"scrolled": true
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Train on 2926 samples, validate on 2926 samples\n",
"Epoch 1/3\n",
"2880/2926 [============================>.] - ETA: 0s - loss: 0.6364 - acc: 0.6495\n",
"Epoch 00001: val_acc improved from -inf to 0.73445, saving model to best_model.h5\n",
"2926/2926 [==============================] - 26s 9ms/sample - loss: 0.6351 - acc: 0.6505 - val_loss: 0.5954 - val_acc: 0.7344\n",
"Epoch 2/3\n",
"2880/2926 [============================>.] - ETA: 0s - loss: 0.4949 - acc: 0.8358\n",
"Epoch 00002: val_acc improved from 0.73445 to 0.78776, saving model to best_model.h5\n",
"2926/2926 [==============================] - 26s 9ms/sample - loss: 0.4925 - acc: 0.8360 - val_loss: 0.4433 - val_acc: 0.7878\n",
"Epoch 3/3\n",
" 896/2926 [========>.....................] - ETA: 13s - loss: 0.2348 - acc: 0.9189WARNING:tensorflow:Early stopping conditioned on metric `val_loss` which is not available. Available metrics are: loss,acc\n",
"WARNING:tensorflow:Can save best model only with val_acc available, skipping.\n"
]
},
{
"ename": "KeyboardInterrupt",
"evalue": "",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)",
"\u001b[1;32m<ipython-input-25-2e866aa85c9f>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m 13\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 14\u001b[0m \u001b[0mmodel\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mcompile\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mloss\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;34m'binary_crossentropy'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0moptimizer\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;34m'adam'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mmetrics\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m'acc'\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 15\u001b[1;33m \u001b[0mmodel\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mfit\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mX_train\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mY_train\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mvalidation_data\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mX_test\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mY_test\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mepochs\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;36m3\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mbatch_size\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;36m64\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mcallbacks\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mes\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mmc\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 16\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;32mC:\\ProgramData\\Anaconda3\\lib\\site-packages\\tensorflow_core\\python\\keras\\engine\\training.py\u001b[0m in \u001b[0;36mfit\u001b[1;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_freq, max_queue_size, workers, use_multiprocessing, **kwargs)\u001b[0m\n\u001b[0;32m 817\u001b[0m \u001b[0mmax_queue_size\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mmax_queue_size\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 818\u001b[0m \u001b[0mworkers\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mworkers\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 819\u001b[1;33m use_multiprocessing=use_multiprocessing)\n\u001b[0m\u001b[0;32m 820\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 821\u001b[0m def evaluate(self,\n",
"\u001b[1;32mC:\\ProgramData\\Anaconda3\\lib\\site-packages\\tensorflow_core\\python\\keras\\engine\\training_v2.py\u001b[0m in \u001b[0;36mfit\u001b[1;34m(self, model, x, y, batch_size, epochs, verbose, callbacks, validation_split, validation_data, shuffle, class_weight, sample_weight, initial_epoch, steps_per_epoch, validation_steps, validation_freq, max_queue_size, workers, use_multiprocessing, **kwargs)\u001b[0m\n\u001b[0;32m 340\u001b[0m \u001b[0mmode\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mModeKeys\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mTRAIN\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 341\u001b[0m \u001b[0mtraining_context\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mtraining_context\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 342\u001b[1;33m total_epochs=epochs)\n\u001b[0m\u001b[0;32m 343\u001b[0m \u001b[0mcbks\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mmake_logs\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mmodel\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mepoch_logs\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mtraining_result\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mModeKeys\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mTRAIN\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 344\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;32mC:\\ProgramData\\Anaconda3\\lib\\site-packages\\tensorflow_core\\python\\keras\\engine\\training_v2.py\u001b[0m in \u001b[0;36mrun_one_epoch\u001b[1;34m(model, iterator, execution_function, dataset_size, batch_size, strategy, steps_per_epoch, num_samples, mode, training_context, total_epochs)\u001b[0m\n\u001b[0;32m 126\u001b[0m step=step, mode=mode, size=current_batch_size) as batch_logs:\n\u001b[0;32m 127\u001b[0m \u001b[1;32mtry\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 128\u001b[1;33m \u001b[0mbatch_outs\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mexecution_function\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0miterator\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 129\u001b[0m \u001b[1;32mexcept\u001b[0m \u001b[1;33m(\u001b[0m\u001b[0mStopIteration\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0merrors\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mOutOfRangeError\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 130\u001b[0m \u001b[1;31m# TODO(kaftan): File bug about tf function and errors.OutOfRangeError?\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;32mC:\\ProgramData\\Anaconda3\\lib\\site-packages\\tensorflow_core\\python\\keras\\engine\\training_v2_utils.py\u001b[0m in \u001b[0;36mexecution_function\u001b[1;34m(input_fn)\u001b[0m\n\u001b[0;32m 96\u001b[0m \u001b[1;31m# `numpy` translates Tensors to values in Eager mode.\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 97\u001b[0m return nest.map_structure(_non_none_constant_value,\n\u001b[1;32m---> 98\u001b[1;33m distributed_function(input_fn))\n\u001b[0m\u001b[0;32m 99\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 100\u001b[0m \u001b[1;32mreturn\u001b[0m \u001b[0mexecution_function\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;32mC:\\ProgramData\\Anaconda3\\lib\\site-packages\\tensorflow_core\\python\\eager\\def_function.py\u001b[0m in \u001b[0;36m__call__\u001b[1;34m(self, *args, **kwds)\u001b[0m\n\u001b[0;32m 566\u001b[0m \u001b[0mxla_context\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mExit\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 567\u001b[0m \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 568\u001b[1;33m \u001b[0mresult\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_call\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m*\u001b[0m\u001b[0margs\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m**\u001b[0m\u001b[0mkwds\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 569\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 570\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0mtracing_count\u001b[0m \u001b[1;33m==\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_get_tracing_count\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;32mC:\\ProgramData\\Anaconda3\\lib\\site-packages\\tensorflow_core\\python\\eager\\def_function.py\u001b[0m in \u001b[0;36m_call\u001b[1;34m(self, *args, **kwds)\u001b[0m\n\u001b[0;32m 597\u001b[0m \u001b[1;31m# In this case we have created variables on the first call, so we run the\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 598\u001b[0m \u001b[1;31m# defunned version which is guaranteed to never create variables.\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 599\u001b[1;33m \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_stateless_fn\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m*\u001b[0m\u001b[0margs\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m**\u001b[0m\u001b[0mkwds\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;31m# pylint: disable=not-callable\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 600\u001b[0m \u001b[1;32melif\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_stateful_fn\u001b[0m \u001b[1;32mis\u001b[0m \u001b[1;32mnot\u001b[0m \u001b[1;32mNone\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 601\u001b[0m \u001b[1;31m# Release the lock early so that multiple threads can perform the call\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;32mC:\\ProgramData\\Anaconda3\\lib\\site-packages\\tensorflow_core\\python\\eager\\function.py\u001b[0m in \u001b[0;36m__call__\u001b[1;34m(self, *args, **kwargs)\u001b[0m\n\u001b[0;32m 2361\u001b[0m \u001b[1;32mwith\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_lock\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 2362\u001b[0m \u001b[0mgraph_function\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0margs\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mkwargs\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_maybe_define_function\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0margs\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mkwargs\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 2363\u001b[1;33m \u001b[1;32mreturn\u001b[0m \u001b[0mgraph_function\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_filtered_call\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0margs\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mkwargs\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;31m# pylint: disable=protected-access\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 2364\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 2365\u001b[0m \u001b[1;33m@\u001b[0m\u001b[0mproperty\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;32mC:\\ProgramData\\Anaconda3\\lib\\site-packages\\tensorflow_core\\python\\eager\\function.py\u001b[0m in \u001b[0;36m_filtered_call\u001b[1;34m(self, args, kwargs)\u001b[0m\n\u001b[0;32m 1609\u001b[0m if isinstance(t, (ops.Tensor,\n\u001b[0;32m 1610\u001b[0m resource_variable_ops.BaseResourceVariable))),\n\u001b[1;32m-> 1611\u001b[1;33m self.captured_inputs)\n\u001b[0m\u001b[0;32m 1612\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 1613\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0m_call_flat\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0margs\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mcaptured_inputs\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mcancellation_manager\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;32mNone\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;32mC:\\ProgramData\\Anaconda3\\lib\\site-packages\\tensorflow_core\\python\\eager\\function.py\u001b[0m in \u001b[0;36m_call_flat\u001b[1;34m(self, args, captured_inputs, cancellation_manager)\u001b[0m\n\u001b[0;32m 1690\u001b[0m \u001b[1;31m# No tape is watching; skip to running the function.\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 1691\u001b[0m return self._build_call_outputs(self._inference_function.call(\n\u001b[1;32m-> 1692\u001b[1;33m ctx, args, cancellation_manager=cancellation_manager))\n\u001b[0m\u001b[0;32m 1693\u001b[0m forward_backward = self._select_forward_and_backward_functions(\n\u001b[0;32m 1694\u001b[0m \u001b[0margs\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;32mC:\\ProgramData\\Anaconda3\\lib\\site-packages\\tensorflow_core\\python\\eager\\function.py\u001b[0m in \u001b[0;36mcall\u001b[1;34m(self, ctx, args, cancellation_manager)\u001b[0m\n\u001b[0;32m 543\u001b[0m \u001b[0minputs\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0margs\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 544\u001b[0m \u001b[0mattrs\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"executor_type\"\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mexecutor_type\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m\"config_proto\"\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mconfig\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 545\u001b[1;33m ctx=ctx)\n\u001b[0m\u001b[0;32m 546\u001b[0m \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 547\u001b[0m outputs = execute.execute_with_cancellation(\n",
"\u001b[1;32mC:\\ProgramData\\Anaconda3\\lib\\site-packages\\tensorflow_core\\python\\eager\\execute.py\u001b[0m in \u001b[0;36mquick_execute\u001b[1;34m(op_name, num_outputs, inputs, attrs, ctx, name)\u001b[0m\n\u001b[0;32m 59\u001b[0m tensors = pywrap_tensorflow.TFE_Py_Execute(ctx._handle, device_name,\n\u001b[0;32m 60\u001b[0m \u001b[0mop_name\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0minputs\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mattrs\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 61\u001b[1;33m num_outputs)\n\u001b[0m\u001b[0;32m 62\u001b[0m \u001b[1;32mexcept\u001b[0m \u001b[0mcore\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_NotOkStatusException\u001b[0m \u001b[1;32mas\u001b[0m \u001b[0me\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 63\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0mname\u001b[0m \u001b[1;32mis\u001b[0m \u001b[1;32mnot\u001b[0m \u001b[1;32mNone\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;31mKeyboardInterrupt\u001b[0m: "
]
}
],
"source": [
"model = Sequential()\n",
"model.add(Embedding(15002, 120))\n",
"model.add(LSTM(128))\n",
"model.add(Dense(2, activation='sigmoid'))\n",
"\n",
"es = EarlyStopping(monitor='val_loss', mode='min', verbose=1, patience=4)\n",
"mc = ModelCheckpoint('best_model.h5', monitor='val_acc', mode='max', verbose=1, save_best_only=True)\n",
"\n",
"X_train = np.array(X_train)\n",
"Y_train = np.array(Y_train)\n",
"X_test = np.array(X_test)\n",
"Y_test = np.array(Y_test)\n",
"\n",
"model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['acc'])\n",
"model.fit(X_train, Y_train, validation_data=(X_test, Y_test), epochs=3, batch_size=64, callbacks=[es, mc])\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 48,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([[9.89297211e-01, 1.10417316e-02],\n",
" [3.73128988e-02, 9.67208505e-01],\n",
" [9.98658895e-01, 1.62478851e-03],\n",
" [9.96271133e-01, 4.04474512e-03],\n",
" [8.88998568e-01, 1.09605283e-01],\n",
" [9.98210311e-01, 2.08193017e-03],\n",
" [3.54536772e-01, 6.69178307e-01],\n",
" [9.85074520e-01, 1.48036592e-02],\n",
" [1.29813954e-01, 8.76039565e-01],\n",
" [9.62996125e-01, 3.44542079e-02],\n",
" [7.55765080e-01, 2.49890730e-01],\n",
" [3.65469605e-01, 6.57850266e-01],\n",
" [9.98800039e-01, 1.51763496e-03],\n",
" [9.97327685e-01, 3.15122958e-03],\n",
" [5.75969875e-01, 4.37167883e-01],\n",
" [9.98559892e-01, 1.73308724e-03],\n",
" [9.83565748e-01, 1.57846343e-02],\n",
" [9.99194920e-01, 1.05460756e-03],\n",
" [9.97159958e-01, 3.05769313e-03],\n",
" [7.86324322e-01, 2.11838797e-01],\n",
" [9.94806945e-01, 5.56808943e-03],\n",
" [9.94939566e-01, 5.16507169e-03],\n",
" [9.95327115e-01, 5.44817653e-03],\n",
" [8.30366760e-02, 9.23830807e-01],\n",
" [9.99270737e-01, 9.99870244e-04],\n",
" [9.98326242e-01, 1.99769647e-03],\n",
" [2.01347172e-01, 8.05066824e-01],\n",
" [9.97681141e-01, 2.63667619e-03],\n",
" [6.56308457e-02, 9.39631820e-01],\n",
" [9.97786045e-01, 2.47393013e-03],\n",
" [9.95178938e-01, 4.89054574e-03],\n",
" [9.98978972e-01, 1.31971261e-03],\n",
" [9.96212244e-01, 3.93838761e-03],\n",
" [8.08125079e-01, 1.83967963e-01],\n",
" [9.86248910e-01, 1.37963891e-02],\n",
" [8.94822180e-01, 9.63397995e-02],\n",
" [4.63879943e-01, 5.36770880e-01],\n",
" [9.90485072e-01, 9.23611410e-03],\n",
" [9.98726070e-01, 1.49498892e-03],\n",
" [9.91048157e-01, 9.32559464e-03],\n",
" [3.64511549e-01, 6.21637642e-01],\n",
" [9.82374847e-01, 1.73149928e-02],\n",
" [9.93298471e-01, 6.45173620e-03],\n",
" [7.04595149e-01, 2.89463103e-01],\n",
" [9.93536115e-01, 6.79136021e-03],\n",
" [9.99129593e-01, 1.11387786e-03],\n",
" [9.06374276e-01, 8.96570683e-02],\n",
" [4.10660505e-01, 5.88741422e-01],\n",
" [9.99692917e-01, 4.83944750e-04],\n",
" [7.80944601e-02, 9.30601835e-01],\n",
" [4.43848312e-01, 5.59155643e-01],\n",
" [1.56105727e-01, 8.51845980e-01],\n",
" [9.82641697e-01, 1.64951906e-02],\n",
" [5.26238121e-02, 9.54043090e-01],\n",
" [9.80851293e-01, 1.90182012e-02],\n",
" [9.90199268e-01, 1.01825390e-02],\n",
" [8.12352419e-01, 1.85036004e-01],\n",
" [9.63351190e-01, 3.39603312e-02],\n",
" [6.31880701e-01, 3.64272743e-01],\n",
" [8.38387251e-01, 1.53711647e-01],\n",
" [9.76741195e-01, 2.20144410e-02],\n",
" [9.90605891e-01, 9.22481064e-03],\n",
" [9.98764873e-01, 1.51382165e-03],\n",
" [9.94506538e-01, 6.27602870e-03],\n",
" [9.97006834e-01, 3.38183786e-03],\n",
" [9.80250001e-01, 1.75612047e-02],\n",
" [8.35835814e-01, 1.54920161e-01],\n",
" [9.93885934e-01, 6.47321297e-03],\n",
" [7.32705653e-01, 2.38107413e-01],\n",
" [1.67823553e-01, 8.28654826e-01],\n",
" [9.97954011e-01, 2.44288007e-03],\n",
" [9.97217536e-01, 3.17463791e-03],\n",
" [9.98234391e-01, 2.21486646e-03],\n",
" [8.36275935e-01, 1.66395113e-01],\n",
" [9.97660041e-01, 2.73835333e-03],\n",
" [9.42627370e-01, 5.81915826e-02],\n",
" [4.82731223e-01, 5.22184551e-01],\n",
" [9.30466115e-01, 6.39836937e-02],\n",
" [5.61084867e-01, 4.41416740e-01],\n",
" [4.50993061e-01, 5.64331651e-01],\n",
" [1.45042473e-02, 9.87169504e-01],\n",
" [9.00123000e-01, 1.01546042e-01],\n",
" [3.05879086e-01, 7.04485118e-01],\n",
" [4.30749863e-01, 5.69399238e-01],\n",
" [1.44111022e-01, 8.66918087e-01],\n",
" [9.00533974e-01, 1.01281039e-01],\n",
" [5.68374395e-01, 4.33054060e-01],\n",
" [9.90041316e-01, 9.53172334e-03],\n",
" [9.87220049e-01, 1.34074753e-02],\n",
" [9.50743973e-01, 5.25186770e-02],\n",
" [2.19779104e-01, 7.77013421e-01],\n",
" [1.54326940e-02, 9.86147463e-01],\n",
" [9.98808622e-01, 1.44694082e-03],\n",
" [8.91158879e-01, 1.06756985e-01],\n",
" [1.05071880e-01, 8.98244858e-01],\n",
" [9.99034405e-01, 1.23475143e-03],\n",
" [9.94593918e-01, 5.76898688e-03],\n",
" [9.93712962e-01, 6.65295729e-03],\n",
" [7.02256203e-01, 2.97228634e-01],\n",
" [9.96766925e-01, 3.70637397e-03],\n",
" [9.89144385e-01, 1.11364387e-02],\n",
" [9.79650915e-01, 2.00015400e-02],\n",
" [9.93528545e-01, 6.56247372e-03],\n",
" [9.87190068e-01, 1.34675717e-02],\n",
" [9.87129986e-01, 1.17099285e-02],\n",
" [9.97617066e-01, 2.67686578e-03],\n",
" [9.97251093e-01, 3.04796081e-03],\n",
" [9.99035120e-01, 1.22244644e-03],\n",
" [9.54006970e-01, 4.89431918e-02],\n",
" [9.46570277e-01, 5.37833124e-02],\n",
" [9.43213701e-01, 5.26795760e-02],\n",
" [9.95134652e-01, 5.25745936e-03],\n",
" [8.25005472e-01, 1.69372976e-01],\n",
" [8.70788097e-01, 1.24156632e-01],\n",
" [9.97023284e-01, 3.26669309e-03],\n",
" [7.92557359e-01, 1.97209224e-01],\n",
" [9.98770893e-01, 1.56408502e-03],\n",
" [9.90018487e-01, 1.06498580e-02],\n",
" [9.90723550e-01, 8.96911696e-03],\n",
" [2.37598643e-01, 7.74325430e-01],\n",
" [6.24084949e-01, 3.58046830e-01],\n",
" [9.97389972e-01, 2.78766919e-03],\n",
" [9.84458208e-01, 1.46457935e-02],\n",
" [9.72309589e-01, 2.36137267e-02],\n",
" [9.98931468e-01, 1.41089316e-03],\n",
" [9.94718015e-01, 5.69924805e-03],\n",
" [4.72977042e-01, 5.49978912e-01],\n",
" [9.90615129e-01, 9.25194938e-03],\n",
" [3.34342234e-02, 9.68245149e-01],\n",
" [9.99083996e-01, 1.16300583e-03],\n",
" [9.44297254e-01, 5.47527708e-02],\n",
" [9.72299933e-01, 2.72788983e-02],\n",
" [9.93855774e-01, 6.32649660e-03],\n",
" [9.62590456e-01, 3.52819376e-02],\n",
" [9.79455829e-01, 1.92554407e-02],\n",
" [9.99165893e-01, 1.05177308e-03],\n",
" [9.85086679e-01, 1.40042715e-02],\n",
" [2.78653465e-02, 9.75346625e-01],\n",
" [9.98081207e-01, 2.21448927e-03],\n",
" [9.95232165e-01, 5.13720512e-03],\n",
" [8.88802350e-01, 1.11462571e-01],\n",
" [9.88667548e-01, 1.16618285e-02],\n",
" [9.98724878e-01, 1.53446209e-03],\n",
" [9.77607906e-01, 2.18318254e-02],\n",
" [9.96304035e-01, 4.18575248e-03],\n",
" [2.64609367e-01, 7.45012462e-01],\n",
" [9.72862959e-01, 2.69199926e-02],\n",
" [9.83956635e-01, 1.73143838e-02],\n",
" [9.98144031e-01, 2.16847914e-03],\n",
" [9.98341322e-01, 1.96177256e-03],\n",
" [9.79604721e-01, 1.93097256e-02],\n",
" [9.98944461e-01, 1.24808261e-03],\n",
" [8.86560798e-01, 1.12452798e-01],\n",
" [9.96718824e-01, 3.71032930e-03],\n",
" [2.21701801e-01, 7.80260146e-01],\n",
" [2.55418997e-02, 9.74908948e-01],\n",
" [9.99462545e-01, 7.41661002e-04],\n",
" [8.23981166e-01, 1.70397952e-01],\n",
" [6.52386248e-02, 9.39590633e-01],\n",
" [9.98122513e-01, 2.17202515e-03],\n",
" [7.12066889e-01, 2.86067158e-01],\n",
" [8.19861591e-02, 9.32014406e-01],\n",
" [9.58634377e-01, 3.82429920e-02],\n",
" [8.24238896e-01, 1.68227255e-01],\n",
" [9.98916030e-01, 1.41686620e-03],\n",
" [9.96592700e-01, 3.68587370e-03],\n",
" [7.33839869e-01, 2.57828295e-01],\n",
" [1.06705025e-01, 8.97602201e-01],\n",
" [3.80194485e-01, 6.08735800e-01],\n",
" [8.97293806e-01, 9.94179696e-02],\n",
" [9.10029948e-01, 8.81575868e-02],\n",
" [9.89466846e-01, 1.07162707e-02],\n",
" [1.63196921e-02, 9.86219883e-01],\n",
" [9.79962826e-01, 1.92297176e-02],\n",
" [9.99110639e-01, 1.11217669e-03],\n",
" [9.98811603e-01, 1.45246438e-03],\n",
" [9.10705030e-01, 8.23124573e-02],\n",
" [9.86083686e-01, 1.50616029e-02],\n",
" [9.94467974e-01, 5.80535224e-03],\n",
" [9.93595064e-01, 6.75331987e-03],\n",
" [9.99255478e-01, 9.77048301e-04],\n",
" [8.52798402e-01, 1.40539274e-01],\n",
" [1.64930165e-01, 8.44964683e-01],\n",
" [9.97384012e-01, 2.95930239e-03],\n",
" [9.96524751e-01, 3.76476254e-03],\n",
" [9.98174548e-01, 2.11151456e-03],\n",
" [6.01421416e-01, 3.98873955e-01],\n",
" [1.82097703e-01, 8.35628331e-01],\n",
" [9.97257769e-01, 3.08231893e-03],\n",
" [6.75210297e-01, 3.04572284e-01],\n",
" [9.53007460e-01, 4.57556657e-02],\n",
" [6.44749761e-01, 3.54564339e-01],\n",
" [9.99813974e-01, 2.97560182e-04],\n",
" [1.71126738e-01, 8.52856874e-01],\n",
" [9.67297077e-01, 3.14390585e-02],\n",
" [2.50648465e-02, 9.78119493e-01],\n",
" [7.36107171e-01, 2.60057181e-01],\n",
" [1.12051122e-01, 8.95975471e-01],\n",
" [9.98990476e-01, 1.27349573e-03],\n",
" [2.98825242e-02, 9.72770095e-01],\n",
" [9.96666729e-01, 3.56671633e-03],\n",
" [9.95280921e-01, 5.05312020e-03],\n",
" [4.67087999e-02, 9.55936015e-01],\n",
" [2.31040847e-02, 9.79663670e-01],\n",
" [9.92311239e-01, 7.36055616e-03],\n",
" [8.72887135e-01, 1.25496492e-01],\n",
" [9.83360767e-01, 1.60082821e-02],\n",
" [2.60338001e-02, 9.78127003e-01],\n",
" [9.79926884e-01, 1.79750286e-02],\n",
" [2.64777075e-02, 9.75348890e-01],\n",
" [8.47916961e-01, 1.61791548e-01],\n",
" [9.91084099e-01, 9.56200063e-03],\n",
" [9.97634172e-01, 2.64891679e-03],\n",
" [9.88843799e-01, 1.17526846e-02],\n",
" [9.99542236e-01, 6.39197184e-04],\n",
" [9.99526381e-01, 6.73291273e-04],\n",
" [9.89566207e-01, 1.05931843e-02],\n",
" [9.84892607e-01, 1.59311239e-02],\n",
" [9.47403908e-01, 5.09829447e-02],\n",
" [9.97905850e-01, 2.34915246e-03],\n",
" [3.12148798e-02, 9.70876515e-01],\n",
" [3.71371321e-02, 9.64185297e-01],\n",
" [2.86366083e-02, 9.73299086e-01],\n",
" [9.98304725e-01, 1.95303746e-03],\n",
" [5.43259323e-01, 4.45621550e-01],\n",
" [9.95735526e-01, 4.47552558e-03],\n",
" [9.99664187e-01, 4.84757824e-04],\n",
" [4.77395892e-01, 5.53484499e-01],\n",
" [2.67982967e-02, 9.75562334e-01],\n",
" [5.11212230e-01, 4.82527465e-01],\n",
" [9.96845663e-01, 3.34183313e-03],\n",
" [9.98655796e-01, 1.58252590e-03],\n",
" [9.98682797e-01, 1.57597498e-03],\n",
" [9.97531652e-01, 2.68543395e-03],\n",
" [8.89724314e-01, 1.02902323e-01],\n",
" [9.96919513e-01, 3.27811856e-03],\n",
" [9.76353884e-01, 2.36234013e-02],\n",
" [9.98018861e-01, 2.27649114e-03],\n",
" [2.69563273e-02, 9.76159155e-01],\n",
" [6.68949783e-02, 9.39164698e-01],\n",
" [9.73651588e-01, 2.52439454e-02],\n",
" [9.98613954e-01, 1.62094866e-03],\n",
" [9.44671273e-01, 5.45767955e-02],\n",
" [4.35869396e-02, 9.60251033e-01],\n",
" [1.88457757e-01, 8.20301712e-01],\n",
" [2.59413511e-01, 7.33782709e-01],\n",
" [5.41639701e-02, 9.47131872e-01],\n",
" [9.19235591e-03, 9.91685688e-01],\n",
" [9.94127393e-01, 5.99407079e-03],\n",
" [9.86760855e-01, 1.31814247e-02],\n",
" [9.78301644e-01, 2.23909188e-02],\n",
" [9.95761573e-01, 4.44441987e-03],\n",
" [9.99497414e-01, 7.02120829e-04],\n",
" [9.97229755e-01, 2.99413246e-03],\n",
" [2.33508293e-02, 9.80765402e-01],\n",
" [9.94520366e-01, 6.04913617e-03],\n",
" [9.97494936e-01, 2.87344446e-03],\n",
" [9.98973131e-01, 1.26466772e-03],\n",
" [4.97004330e-01, 4.97818023e-01],\n",
" [9.82652664e-01, 1.84881184e-02],\n",
" [1.31787378e-02, 9.88159657e-01],\n",
" [3.66922885e-01, 6.31668866e-01],\n",
" [9.96259332e-01, 4.08321712e-03],\n",
" [9.98756170e-01, 1.47667748e-03],\n",
" [7.72360861e-02, 9.27823484e-01],\n",
" [9.98449206e-01, 1.86312699e-03],\n",
" [3.15861739e-02, 9.71484125e-01],\n",
" [9.96845782e-01, 3.44880344e-03],\n",
" [7.42987245e-02, 9.30592895e-01],\n",
" [2.09757891e-02, 9.81689215e-01],\n",
" [9.98074651e-01, 2.20919168e-03],\n",
" [6.46533668e-01, 3.48830134e-01],\n",
" [5.98557949e-01, 3.84560645e-01],\n",
" [9.99404311e-01, 7.86028046e-04],\n",
" [9.98620272e-01, 1.63661852e-03],\n",
" [9.99131620e-01, 1.08906056e-03],\n",
" [3.69940363e-02, 9.68174577e-01],\n",
" [9.98901844e-01, 1.32231705e-03],\n",
" [9.85736310e-01, 1.49741964e-02],\n",
" [6.43389583e-01, 3.48876834e-01],\n",
" [4.78291005e-01, 5.33889949e-01],\n",
" [9.99354661e-01, 8.77332001e-04],\n",
" [5.98759837e-02, 9.42334712e-01],\n",
" [9.63255167e-01, 3.59756313e-02],\n",
" [2.05777939e-02, 9.81795371e-01],\n",
" [8.92112032e-02, 9.14921701e-01],\n",
" [9.96331871e-01, 4.17977013e-03],\n",
" [5.23199812e-02, 9.52406943e-01],\n",
" [9.88084376e-01, 1.19793927e-02],\n",
" [9.69554842e-01, 2.73279194e-02],\n",
" [3.67223620e-01, 6.27295792e-01],\n",
" [9.16537941e-01, 8.18802044e-02],\n",
" [9.99439061e-01, 7.88773061e-04],\n",
" [2.48765163e-02, 9.77342725e-01],\n",
" [9.96949136e-01, 3.68632539e-03],\n",
" [6.32767797e-01, 3.68138403e-01],\n",
" [9.95043516e-01, 5.14345011e-03],\n",
" [9.93900299e-01, 6.20957604e-03],\n",
" [9.97990847e-01, 2.28208210e-03],\n",
" [8.38533640e-02, 9.23523605e-01],\n",
" [9.93036926e-01, 6.87335012e-03],\n",
" [9.56128418e-01, 4.12139818e-02],\n",
" [9.56128418e-01, 4.12139818e-02],\n",
" [1.26801789e-01, 8.76263022e-01],\n",
" [2.42131352e-01, 7.80837834e-01],\n",
" [8.39236677e-01, 1.56546742e-01],\n",
" [9.98509943e-01, 1.75377598e-03]], dtype=float32)"
]
},
"execution_count": 48,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"M_test = pad_sequences(M_test, maxlen=max_len)\n",
"\n",
"predictions = model.predict(M_test)\n",
"predictions"
]
},
{
"cell_type": "code",
"execution_count": 49,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([[9.89297211e-01, 1.10417316e-02],\n",
" [3.73128988e-02, 9.67208505e-01],\n",
" [9.98658895e-01, 1.62478851e-03],\n",
" [9.96271133e-01, 4.04474512e-03],\n",
" [8.88998568e-01, 1.09605283e-01],\n",
" [9.98210311e-01, 2.08193017e-03],\n",
" [3.54536772e-01, 6.69178307e-01],\n",
" [9.85074520e-01, 1.48036592e-02],\n",
" [1.29813954e-01, 8.76039565e-01],\n",
" [9.62996125e-01, 3.44542079e-02],\n",
" [7.55765080e-01, 2.49890730e-01],\n",
" [3.65469605e-01, 6.57850266e-01],\n",
" [9.98800039e-01, 1.51763496e-03],\n",
" [9.97327685e-01, 3.15122958e-03],\n",
" [5.75969875e-01, 4.37167883e-01],\n",
" [9.98559892e-01, 1.73308724e-03],\n",
" [9.83565748e-01, 1.57846343e-02],\n",
" [9.99194920e-01, 1.05460756e-03],\n",
" [9.97159958e-01, 3.05769313e-03],\n",
" [7.86324322e-01, 2.11838797e-01],\n",
" [9.94806945e-01, 5.56808943e-03],\n",
" [9.94939566e-01, 5.16507169e-03],\n",
" [9.95327115e-01, 5.44817653e-03],\n",
" [8.30366760e-02, 9.23830807e-01],\n",
" [9.99270737e-01, 9.99870244e-04],\n",
" [9.98326242e-01, 1.99769647e-03],\n",
" [2.01347172e-01, 8.05066824e-01],\n",
" [9.97681141e-01, 2.63667619e-03],\n",
" [6.56308457e-02, 9.39631820e-01],\n",
" [9.97786045e-01, 2.47393013e-03],\n",
" [9.95178938e-01, 4.89054574e-03],\n",
" [9.98978972e-01, 1.31971261e-03],\n",
" [9.96212244e-01, 3.93838761e-03],\n",
" [8.08125079e-01, 1.83967963e-01],\n",
" [9.86248910e-01, 1.37963891e-02],\n",
" [8.94822180e-01, 9.63397995e-02],\n",
" [4.63879943e-01, 5.36770880e-01],\n",
" [9.90485072e-01, 9.23611410e-03],\n",
" [9.98726070e-01, 1.49498892e-03],\n",
" [9.91048157e-01, 9.32559464e-03],\n",
" [3.64511549e-01, 6.21637642e-01],\n",
" [9.82374847e-01, 1.73149928e-02],\n",
" [9.93298471e-01, 6.45173620e-03],\n",
" [7.04595149e-01, 2.89463103e-01],\n",
" [9.93536115e-01, 6.79136021e-03],\n",
" [9.99129593e-01, 1.11387786e-03],\n",
" [9.06374276e-01, 8.96570683e-02],\n",
" [4.10660505e-01, 5.88741422e-01],\n",
" [9.99692917e-01, 4.83944750e-04],\n",
" [7.80944601e-02, 9.30601835e-01],\n",
" [4.43848312e-01, 5.59155643e-01],\n",
" [1.56105727e-01, 8.51845980e-01],\n",
" [9.82641697e-01, 1.64951906e-02],\n",
" [5.26238121e-02, 9.54043090e-01],\n",
" [9.80851293e-01, 1.90182012e-02],\n",
" [9.90199268e-01, 1.01825390e-02],\n",
" [8.12352419e-01, 1.85036004e-01],\n",
" [9.63351190e-01, 3.39603312e-02],\n",
" [6.31880701e-01, 3.64272743e-01],\n",
" [8.38387251e-01, 1.53711647e-01],\n",
" [9.76741195e-01, 2.20144410e-02],\n",
" [9.90605891e-01, 9.22481064e-03],\n",
" [9.98764873e-01, 1.51382165e-03],\n",
" [9.94506538e-01, 6.27602870e-03],\n",
" [9.97006834e-01, 3.38183786e-03],\n",
" [9.80250001e-01, 1.75612047e-02],\n",
" [8.35835814e-01, 1.54920161e-01],\n",
" [9.93885934e-01, 6.47321297e-03],\n",
" [7.32705653e-01, 2.38107413e-01],\n",
" [1.67823553e-01, 8.28654826e-01],\n",
" [9.97954011e-01, 2.44288007e-03],\n",
" [9.97217536e-01, 3.17463791e-03],\n",
" [9.98234391e-01, 2.21486646e-03],\n",
" [8.36275935e-01, 1.66395113e-01],\n",
" [9.97660041e-01, 2.73835333e-03],\n",
" [9.42627370e-01, 5.81915826e-02],\n",
" [4.82731223e-01, 5.22184551e-01],\n",
" [9.30466115e-01, 6.39836937e-02],\n",
" [5.61084867e-01, 4.41416740e-01],\n",
" [4.50993061e-01, 5.64331651e-01],\n",
" [1.45042473e-02, 9.87169504e-01],\n",
" [9.00123000e-01, 1.01546042e-01],\n",
" [3.05879086e-01, 7.04485118e-01],\n",
" [4.30749863e-01, 5.69399238e-01],\n",
" [1.44111022e-01, 8.66918087e-01],\n",
" [9.00533974e-01, 1.01281039e-01],\n",
" [5.68374395e-01, 4.33054060e-01],\n",
" [9.90041316e-01, 9.53172334e-03],\n",
" [9.87220049e-01, 1.34074753e-02],\n",
" [9.50743973e-01, 5.25186770e-02],\n",
" [2.19779104e-01, 7.77013421e-01],\n",
" [1.54326940e-02, 9.86147463e-01],\n",
" [9.98808622e-01, 1.44694082e-03],\n",
" [8.91158879e-01, 1.06756985e-01],\n",
" [1.05071880e-01, 8.98244858e-01],\n",
" [9.99034405e-01, 1.23475143e-03],\n",
" [9.94593918e-01, 5.76898688e-03],\n",
" [9.93712962e-01, 6.65295729e-03],\n",
" [7.02256203e-01, 2.97228634e-01],\n",
" [9.96766925e-01, 3.70637397e-03],\n",
" [9.89144385e-01, 1.11364387e-02],\n",
" [9.79650915e-01, 2.00015400e-02],\n",
" [9.93528545e-01, 6.56247372e-03],\n",
" [9.87190068e-01, 1.34675717e-02],\n",
" [9.87129986e-01, 1.17099285e-02],\n",
" [9.97617066e-01, 2.67686578e-03],\n",
" [9.97251093e-01, 3.04796081e-03],\n",
" [9.99035120e-01, 1.22244644e-03],\n",
" [9.54006970e-01, 4.89431918e-02],\n",
" [9.46570277e-01, 5.37833124e-02],\n",
" [9.43213701e-01, 5.26795760e-02],\n",
" [9.95134652e-01, 5.25745936e-03],\n",
" [8.25005472e-01, 1.69372976e-01],\n",
" [8.70788097e-01, 1.24156632e-01],\n",
" [9.97023284e-01, 3.26669309e-03],\n",
" [7.92557359e-01, 1.97209224e-01],\n",
" [9.98770893e-01, 1.56408502e-03],\n",
" [9.90018487e-01, 1.06498580e-02],\n",
" [9.90723550e-01, 8.96911696e-03],\n",
" [2.37598643e-01, 7.74325430e-01],\n",
" [6.24084949e-01, 3.58046830e-01],\n",
" [9.97389972e-01, 2.78766919e-03],\n",
" [9.84458208e-01, 1.46457935e-02],\n",
" [9.72309589e-01, 2.36137267e-02],\n",
" [9.98931468e-01, 1.41089316e-03],\n",
" [9.94718015e-01, 5.69924805e-03],\n",
" [4.72977042e-01, 5.49978912e-01],\n",
" [9.90615129e-01, 9.25194938e-03],\n",
" [3.34342234e-02, 9.68245149e-01],\n",
" [9.99083996e-01, 1.16300583e-03],\n",
" [9.44297254e-01, 5.47527708e-02],\n",
" [9.72299933e-01, 2.72788983e-02],\n",
" [9.93855774e-01, 6.32649660e-03],\n",
" [9.62590456e-01, 3.52819376e-02],\n",
" [9.79455829e-01, 1.92554407e-02],\n",
" [9.99165893e-01, 1.05177308e-03],\n",
" [9.85086679e-01, 1.40042715e-02],\n",
" [2.78653465e-02, 9.75346625e-01],\n",
" [9.98081207e-01, 2.21448927e-03],\n",
" [9.95232165e-01, 5.13720512e-03],\n",
" [8.88802350e-01, 1.11462571e-01],\n",
" [9.88667548e-01, 1.16618285e-02],\n",
" [9.98724878e-01, 1.53446209e-03],\n",
" [9.77607906e-01, 2.18318254e-02],\n",
" [9.96304035e-01, 4.18575248e-03],\n",
" [2.64609367e-01, 7.45012462e-01],\n",
" [9.72862959e-01, 2.69199926e-02],\n",
" [9.83956635e-01, 1.73143838e-02],\n",
" [9.98144031e-01, 2.16847914e-03],\n",
" [9.98341322e-01, 1.96177256e-03],\n",
" [9.79604721e-01, 1.93097256e-02],\n",
" [9.98944461e-01, 1.24808261e-03],\n",
" [8.86560798e-01, 1.12452798e-01],\n",
" [9.96718824e-01, 3.71032930e-03],\n",
" [2.21701801e-01, 7.80260146e-01],\n",
" [2.55418997e-02, 9.74908948e-01],\n",
" [9.99462545e-01, 7.41661002e-04],\n",
" [8.23981166e-01, 1.70397952e-01],\n",
" [6.52386248e-02, 9.39590633e-01],\n",
" [9.98122513e-01, 2.17202515e-03],\n",
" [7.12066889e-01, 2.86067158e-01],\n",
" [8.19861591e-02, 9.32014406e-01],\n",
" [9.58634377e-01, 3.82429920e-02],\n",
" [8.24238896e-01, 1.68227255e-01],\n",
" [9.98916030e-01, 1.41686620e-03],\n",
" [9.96592700e-01, 3.68587370e-03],\n",
" [7.33839869e-01, 2.57828295e-01],\n",
" [1.06705025e-01, 8.97602201e-01],\n",
" [3.80194485e-01, 6.08735800e-01],\n",
" [8.97293806e-01, 9.94179696e-02],\n",
" [9.10029948e-01, 8.81575868e-02],\n",
" [9.89466846e-01, 1.07162707e-02],\n",
" [1.63196921e-02, 9.86219883e-01],\n",
" [9.79962826e-01, 1.92297176e-02],\n",
" [9.99110639e-01, 1.11217669e-03],\n",
" [9.98811603e-01, 1.45246438e-03],\n",
" [9.10705030e-01, 8.23124573e-02],\n",
" [9.86083686e-01, 1.50616029e-02],\n",
" [9.94467974e-01, 5.80535224e-03],\n",
" [9.93595064e-01, 6.75331987e-03],\n",
" [9.99255478e-01, 9.77048301e-04],\n",
" [8.52798402e-01, 1.40539274e-01],\n",
" [1.64930165e-01, 8.44964683e-01],\n",
" [9.97384012e-01, 2.95930239e-03],\n",
" [9.96524751e-01, 3.76476254e-03],\n",
" [9.98174548e-01, 2.11151456e-03],\n",
" [6.01421416e-01, 3.98873955e-01],\n",
" [1.82097703e-01, 8.35628331e-01],\n",
" [9.97257769e-01, 3.08231893e-03],\n",
" [6.75210297e-01, 3.04572284e-01],\n",
" [9.53007460e-01, 4.57556657e-02],\n",
" [6.44749761e-01, 3.54564339e-01],\n",
" [9.99813974e-01, 2.97560182e-04],\n",
" [1.71126738e-01, 8.52856874e-01],\n",
" [9.67297077e-01, 3.14390585e-02],\n",
" [2.50648465e-02, 9.78119493e-01],\n",
" [7.36107171e-01, 2.60057181e-01],\n",
" [1.12051122e-01, 8.95975471e-01],\n",
" [9.98990476e-01, 1.27349573e-03],\n",
" [2.98825242e-02, 9.72770095e-01],\n",
" [9.96666729e-01, 3.56671633e-03],\n",
" [9.95280921e-01, 5.05312020e-03],\n",
" [4.67087999e-02, 9.55936015e-01],\n",
" [2.31040847e-02, 9.79663670e-01],\n",
" [9.92311239e-01, 7.36055616e-03],\n",
" [8.72887135e-01, 1.25496492e-01],\n",
" [9.83360767e-01, 1.60082821e-02],\n",
" [2.60338001e-02, 9.78127003e-01],\n",
" [9.79926884e-01, 1.79750286e-02],\n",
" [2.64777075e-02, 9.75348890e-01],\n",
" [8.47916961e-01, 1.61791548e-01],\n",
" [9.91084099e-01, 9.56200063e-03],\n",
" [9.97634172e-01, 2.64891679e-03],\n",
" [9.88843799e-01, 1.17526846e-02],\n",
" [9.99542236e-01, 6.39197184e-04],\n",
" [9.99526381e-01, 6.73291273e-04],\n",
" [9.89566207e-01, 1.05931843e-02],\n",
" [9.84892607e-01, 1.59311239e-02],\n",
" [9.47403908e-01, 5.09829447e-02],\n",
" [9.97905850e-01, 2.34915246e-03],\n",
" [3.12148798e-02, 9.70876515e-01],\n",
" [3.71371321e-02, 9.64185297e-01],\n",
" [2.86366083e-02, 9.73299086e-01],\n",
" [9.98304725e-01, 1.95303746e-03],\n",
" [5.43259323e-01, 4.45621550e-01],\n",
" [9.95735526e-01, 4.47552558e-03],\n",
" [9.99664187e-01, 4.84757824e-04],\n",
" [4.77395892e-01, 5.53484499e-01],\n",
" [2.67982967e-02, 9.75562334e-01],\n",
" [5.11212230e-01, 4.82527465e-01],\n",
" [9.96845663e-01, 3.34183313e-03],\n",
" [9.98655796e-01, 1.58252590e-03],\n",
" [9.98682797e-01, 1.57597498e-03],\n",
" [9.97531652e-01, 2.68543395e-03],\n",
" [8.89724314e-01, 1.02902323e-01],\n",
" [9.96919513e-01, 3.27811856e-03],\n",
" [9.76353884e-01, 2.36234013e-02],\n",
" [9.98018861e-01, 2.27649114e-03],\n",
" [2.69563273e-02, 9.76159155e-01],\n",
" [6.68949783e-02, 9.39164698e-01],\n",
" [9.73651588e-01, 2.52439454e-02],\n",
" [9.98613954e-01, 1.62094866e-03],\n",
" [9.44671273e-01, 5.45767955e-02],\n",
" [4.35869396e-02, 9.60251033e-01],\n",
" [1.88457757e-01, 8.20301712e-01],\n",
" [2.59413511e-01, 7.33782709e-01],\n",
" [5.41639701e-02, 9.47131872e-01],\n",
" [9.19235591e-03, 9.91685688e-01],\n",
" [9.94127393e-01, 5.99407079e-03],\n",
" [9.86760855e-01, 1.31814247e-02],\n",
" [9.78301644e-01, 2.23909188e-02],\n",
" [9.95761573e-01, 4.44441987e-03],\n",
" [9.99497414e-01, 7.02120829e-04],\n",
" [9.97229755e-01, 2.99413246e-03],\n",
" [2.33508293e-02, 9.80765402e-01],\n",
" [9.94520366e-01, 6.04913617e-03],\n",
" [9.97494936e-01, 2.87344446e-03],\n",
" [9.98973131e-01, 1.26466772e-03],\n",
" [4.97004330e-01, 4.97818023e-01],\n",
" [9.82652664e-01, 1.84881184e-02],\n",
" [1.31787378e-02, 9.88159657e-01],\n",
" [3.66922885e-01, 6.31668866e-01],\n",
" [9.96259332e-01, 4.08321712e-03],\n",
" [9.98756170e-01, 1.47667748e-03],\n",
" [7.72360861e-02, 9.27823484e-01],\n",
" [9.98449206e-01, 1.86312699e-03],\n",
" [3.15861739e-02, 9.71484125e-01],\n",
" [9.96845782e-01, 3.44880344e-03],\n",
" [7.42987245e-02, 9.30592895e-01],\n",
" [2.09757891e-02, 9.81689215e-01],\n",
" [9.98074651e-01, 2.20919168e-03],\n",
" [6.46533668e-01, 3.48830134e-01],\n",
" [5.98557949e-01, 3.84560645e-01],\n",
" [9.99404311e-01, 7.86028046e-04],\n",
" [9.98620272e-01, 1.63661852e-03],\n",
" [9.99131620e-01, 1.08906056e-03],\n",
" [3.69940363e-02, 9.68174577e-01],\n",
" [9.98901844e-01, 1.32231705e-03],\n",
" [9.85736310e-01, 1.49741964e-02],\n",
" [6.43389583e-01, 3.48876834e-01],\n",
" [4.78291005e-01, 5.33889949e-01],\n",
" [9.99354661e-01, 8.77332001e-04],\n",
" [5.98759837e-02, 9.42334712e-01],\n",
" [9.63255167e-01, 3.59756313e-02],\n",
" [2.05777939e-02, 9.81795371e-01],\n",
" [8.92112032e-02, 9.14921701e-01],\n",
" [9.96331871e-01, 4.17977013e-03],\n",
" [5.23199812e-02, 9.52406943e-01],\n",
" [9.88084376e-01, 1.19793927e-02],\n",
" [9.69554842e-01, 2.73279194e-02],\n",
" [3.67223620e-01, 6.27295792e-01],\n",
" [9.16537941e-01, 8.18802044e-02],\n",
" [9.99439061e-01, 7.88773061e-04],\n",
" [2.48765163e-02, 9.77342725e-01],\n",
" [9.96949136e-01, 3.68632539e-03],\n",
" [6.32767797e-01, 3.68138403e-01],\n",
" [9.95043516e-01, 5.14345011e-03],\n",
" [9.93900299e-01, 6.20957604e-03],\n",
" [9.97990847e-01, 2.28208210e-03],\n",
" [8.38533640e-02, 9.23523605e-01],\n",
" [9.93036926e-01, 6.87335012e-03],\n",
" [9.56128418e-01, 4.12139818e-02],\n",
" [9.56128418e-01, 4.12139818e-02],\n",
" [1.26801789e-01, 8.76263022e-01],\n",
" [2.42131352e-01, 7.80837834e-01],\n",
" [8.39236677e-01, 1.56546742e-01],\n",
" [9.98509943e-01, 1.75377598e-03]], dtype=float32)"
]
},
"execution_count": 49,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"predictions"
]
},
{
"cell_type": "code",
"execution_count": 51,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"스릴러일 확률 (1) 0.2028985507246377\n",
"로맨스일 확률 (0) 0.7971014492753623\n"
]
}
],
"source": [
"import numpy as np\n",
"predict_labels = np.argmax(predictions, axis = 1)\n",
"th_tot = 0\n",
"ro_tot = 0\n",
"for i in range(69):\n",
" if(predict_labels[i]==1):\n",
" th_tot += 1\n",
" else:\n",
" ro_tot += 1\n",
"print(\"스릴러일 확률 (1) \" , th_tot / 69)\n",
"print(\"로맨스일 확률 (0) \" , ro_tot / 69)\n",
"\n",
" "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 판타지 VS 사회"
]
},
{
"cell_type": "code",
"execution_count": 37,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"줄거리 최대 길이 : 2324\n",
"줄거리 평균 길이 : 275.97285714285715\n"
]
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAX0AAAD4CAYAAAAAczaOAAAABHNCSVQICAgIfAhkiA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LuY4aZD7yVdRMzyB9ExKSOApT0F8DSiPjv6fFXgM9GxB3D1lsLrE0PPwW8PMKPzNPvME/bCpXb3hE/11W9pz/Z/xnzSFJ/RDRl3UfOjHmkORSONge2jvnDcvQ7zNO2QnVsr8f0zSbPR5rbjOHQN5s8H2luM0ZVD+/YhIw5fGBTaxqONM/T7zBP2wpVsL1V/UWumZlNLQ/vmJnliEPfzCxHHPo1QFK3pKOS9mbdi02cpKWSXpZ0QNKGrPuZqFKfR0nzJO2WtD/dz011Sfp+2uYXJV1d9JrVaf39klZnsS1jkXSFpF5JA5JekvT1VK/e7R3vFZh8q74b8AXgamBv1r34NuHfYR3wCvAJYDbwa2Bx1n1NcFvO+zwCfwtsSMsbgM1peTnwBIVjHa4Ffpnq84BX0/3ctDw3620rsa2XAVen5YuAf6NwKo6q3V7v6deAiHgaOJZ1HzYpZ0/lEBGngKFTOcw4I3weVwDb0/J2YGVR/ZEoeAa4WNJlwE3A7og4FhHvALuBpdPf/fhExOGIeD4tHwcGKFz3u2q316FvVh0uB14venwo1WrFpRFxGApBCVyS6iNt94z77yGpHvgM8EuqeHsd+mbVoaxTOdSgkbZ7Rv33kPRx4FHgGxHx3mirlqhVdHsd+mbVodZP5XAkDWOQ7o+m+kjbPWP+e0iaRSHwfxARP0nlqt1eh75Zdaj1UznsBIZmpKwGHiuq35pmtVwLvJuGQ54EbpQ0N818uTHVqookAV3AQER8t+ip6t3erL/99m3yN6AHOAycprDH0JZ1T75N6Pe4nMLsj1eAjqz7mcR2nPd5BH4feArYn+7npXVF4QI0rwC/AZqKfs4a4EC6fTXr7RphW5spDMO8COxJt+XVvL0+DYOZWY54eMfMLEcc+mZmOeLQNzPLEYe+mVmOOPTNzHLEoW9mliMOfTOzHPn/9Gsy4cbxH3oAAAAASUVORK5CYII=\n",
"text/plain": [
"<Figure size 432x288 with 2 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"#판타지 사회\n",
"FS_X_train = []\n",
"FS_Y_train = [] \n",
"\n",
"FStrain_data_size = 1400//2\n",
"\n",
"for i in range(FStrain_data_size):\n",
" FS_X_train.append(SC_encoded[i])\n",
" FS_Y_train.append([1,0])\n",
" FS_X_train.append(FN_encoded[i])\n",
" FS_Y_train.append([0,1])\n",
" \n",
"import matplotlib.pyplot as plt\n",
"%matplotlib inline\n",
"\n",
"len_result = [len(s) for s in FS_X_train]\n",
"print(\"줄거리 최대 길이 : \",max(len_result))\n",
"print(\"줄거리 평균 길이 : \",sum(len_result)/len(len_result))\n",
"\n",
"plt.subplot(1,2,1)\n",
"plt.boxplot(len_result)\n",
"plt.subplot(1,2,2)\n",
"plt.hist(len_result, bins=50)\n",
"plt.show()\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 38,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"줄거리 최대 길이 : 1336\n",
"줄거리 평균 길이 : 193.3892857142857\n"
]
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAX0AAAD8CAYAAACb4nSYAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjMsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+AADFEAAAeqklEQVR4nO3df5DU9Z3n8eeLAeHCGsSInILcmCzrDUttDDdlvHOSysQV1KSCuax7gpVwzpwEI5x7eiXEqTpjspPIbRJ3w22wyM6cWhVGPY2RUjZImclaVEVX/BGDjhFiCI6wggsqgYAMvO+P/gzpGXpmeqZnpnu6X4+qrv5+P9/vt/vdOrz705/v54ciAjMzqwzjih2AmZmNHid9M7MK4qRvZlZBnPTNzCqIk76ZWQVx0jczqyADJn1JrZL2StqW49j/lBSSzkr7kvQ9STskvSRpXta5SyRtT48lw/sxzMwsH/nU9O8BLu9dKOk84DJgV1bxFcDs9FgKrE3nngncDnwcuAi4XdLUQgI3M7PBGzDpR8RTw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fK5/LXTbNSsSAS4mWsEsiYreks4HNkl7t59yx/Dmh7/jHzOdyTd+sNIzZpUQjYnd63gs8Qqap6q3uZpv0vDedPlY+52DjHyufy0nfrESMyakcJE2WdHr3NjAf2EYm9u4eLEuAR9P2BuBLqRfMxcC73c0oJWaw8W8C5kuamm7gzk9lJcfNO2VAUhvwKeAsSZ3A7RHRUtyobDDG8FQO04FHJEEmn6yPiJ9IehZ4UFIjsAu4Op2/EbgS2AEcBq4b/ZB7yvXvB7iTQcQfEfslfYPMlzfA1yOiJDtXeESumVkFcfOOmVkFcdI3M6sgTvpmZhXESd/MrII46ZuZVRAnfTOzCuKkb2ZWQZz0zcwqyP8HJuEojPlrMPEAAAAASUVORK5CYII=\n",
"text/plain": [
"<Figure size 432x288 with 2 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"FS_X_test = []\n",
"FS_Y_test = [] #0 : romance, 1 : thriller \n",
"\n",
"for i in range(FStrain_data_size):\n",
" FS_X_test.append(SC_encoded[FStrain_data_size+i])\n",
" FS_Y_test.append([1,0])\n",
" FS_X_test.append(FN_encoded[FStrain_data_size+i])\n",
" FS_Y_test.append([0,1])\n",
"\n",
"import matplotlib.pyplot as plt\n",
"%matplotlib inline\n",
"\n",
"len_result = [len(s) for s in FS_X_test]\n",
"print(\"줄거리 최대 길이 : \",max(len_result))\n",
"print(\"줄거리 평균 길이 : \",sum(len_result)/len(len_result))\n",
"\n",
"plt.subplot(1,2,1)\n",
"plt.boxplot(len_result)\n",
"plt.subplot(1,2,2)\n",
"plt.hist(len_result, bins=50)\n",
"plt.show()\n"
]
},
{
"cell_type": "code",
"execution_count": 39,
"metadata": {},
"outputs": [],
"source": [
"max_len = 230\n",
"\n",
"FS_X_train = pad_sequences(FS_X_train, maxlen=max_len)\n",
"FS_X_test = pad_sequences(FS_X_test, maxlen=max_len)\n"
]
},
{
"cell_type": "code",
"execution_count": 44,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Train on 1400 samples, validate on 1400 samples\n",
"Epoch 1/3\n",
" 64/1400 [>.............................] - ETA: 27sWARNING:tensorflow:Early stopping conditioned on metric `val_loss` which is not available. Available metrics are: \n",
"WARNING:tensorflow:Can save best model only with val_acc available, skipping.\n"
]
},
{
"ename": "InvalidArgumentError",
"evalue": " indices[54,195] = 8646 is not in [0, 5002)\n\t [[node sequential_6/embedding_6/embedding_lookup (defined at <ipython-input-44-4c2962189ab4>:16) ]] [Op:__inference_distributed_function_13289]\n\nErrors may have originated from an input operation.\nInput Source operations connected to node sequential_6/embedding_6/embedding_lookup:\n sequential_6/embedding_6/embedding_lookup/12144 (defined at C:\\ProgramData\\Anaconda3\\lib\\contextlib.py:112)\n\nFunction call stack:\ndistributed_function\n",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mInvalidArgumentError\u001b[0m Traceback (most recent call last)",
"\u001b[1;32m<ipython-input-44-4c2962189ab4>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m 14\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 15\u001b[0m \u001b[0mmodel\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mcompile\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mloss\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;34m'binary_crossentropy'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0moptimizer\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;34m'adam'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mmetrics\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m'acc'\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 16\u001b[1;33m \u001b[0mmodel\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mfit\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mFS_X_train\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mFS_Y_train\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mvalidation_data\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mFS_X_test\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mFS_Y_test\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mepochs\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;36m3\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mbatch_size\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;36m64\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mcallbacks\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mes\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mmc\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[1;32mC:\\ProgramData\\Anaconda3\\lib\\site-packages\\tensorflow_core\\python\\keras\\engine\\training.py\u001b[0m in \u001b[0;36mfit\u001b[1;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_freq, max_queue_size, workers, use_multiprocessing, **kwargs)\u001b[0m\n\u001b[0;32m 817\u001b[0m \u001b[0mmax_queue_size\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mmax_queue_size\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 818\u001b[0m \u001b[0mworkers\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mworkers\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 819\u001b[1;33m use_multiprocessing=use_multiprocessing)\n\u001b[0m\u001b[0;32m 820\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 821\u001b[0m def evaluate(self,\n",
"\u001b[1;32mC:\\ProgramData\\Anaconda3\\lib\\site-packages\\tensorflow_core\\python\\keras\\engine\\training_v2.py\u001b[0m in \u001b[0;36mfit\u001b[1;34m(self, model, x, y, batch_size, epochs, verbose, callbacks, validation_split, validation_data, shuffle, class_weight, sample_weight, initial_epoch, steps_per_epoch, validation_steps, validation_freq, max_queue_size, workers, use_multiprocessing, **kwargs)\u001b[0m\n\u001b[0;32m 340\u001b[0m \u001b[0mmode\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mModeKeys\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mTRAIN\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 341\u001b[0m \u001b[0mtraining_context\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mtraining_context\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 342\u001b[1;33m total_epochs=epochs)\n\u001b[0m\u001b[0;32m 343\u001b[0m \u001b[0mcbks\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mmake_logs\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mmodel\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mepoch_logs\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mtraining_result\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mModeKeys\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mTRAIN\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 344\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;32mC:\\ProgramData\\Anaconda3\\lib\\site-packages\\tensorflow_core\\python\\keras\\engine\\training_v2.py\u001b[0m in \u001b[0;36mrun_one_epoch\u001b[1;34m(model, iterator, execution_function, dataset_size, batch_size, strategy, steps_per_epoch, num_samples, mode, training_context, total_epochs)\u001b[0m\n\u001b[0;32m 126\u001b[0m step=step, mode=mode, size=current_batch_size) as batch_logs:\n\u001b[0;32m 127\u001b[0m \u001b[1;32mtry\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 128\u001b[1;33m \u001b[0mbatch_outs\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mexecution_function\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0miterator\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 129\u001b[0m \u001b[1;32mexcept\u001b[0m \u001b[1;33m(\u001b[0m\u001b[0mStopIteration\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0merrors\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mOutOfRangeError\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 130\u001b[0m \u001b[1;31m# TODO(kaftan): File bug about tf function and errors.OutOfRangeError?\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;32mC:\\ProgramData\\Anaconda3\\lib\\site-packages\\tensorflow_core\\python\\keras\\engine\\training_v2_utils.py\u001b[0m in \u001b[0;36mexecution_function\u001b[1;34m(input_fn)\u001b[0m\n\u001b[0;32m 96\u001b[0m \u001b[1;31m# `numpy` translates Tensors to values in Eager mode.\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 97\u001b[0m return nest.map_structure(_non_none_constant_value,\n\u001b[1;32m---> 98\u001b[1;33m distributed_function(input_fn))\n\u001b[0m\u001b[0;32m 99\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 100\u001b[0m \u001b[1;32mreturn\u001b[0m \u001b[0mexecution_function\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;32mC:\\ProgramData\\Anaconda3\\lib\\site-packages\\tensorflow_core\\python\\eager\\def_function.py\u001b[0m in \u001b[0;36m__call__\u001b[1;34m(self, *args, **kwds)\u001b[0m\n\u001b[0;32m 566\u001b[0m \u001b[0mxla_context\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mExit\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 567\u001b[0m \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 568\u001b[1;33m \u001b[0mresult\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_call\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m*\u001b[0m\u001b[0margs\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m**\u001b[0m\u001b[0mkwds\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 569\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 570\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0mtracing_count\u001b[0m \u001b[1;33m==\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_get_tracing_count\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;32mC:\\ProgramData\\Anaconda3\\lib\\site-packages\\tensorflow_core\\python\\eager\\def_function.py\u001b[0m in \u001b[0;36m_call\u001b[1;34m(self, *args, **kwds)\u001b[0m\n\u001b[0;32m 630\u001b[0m \u001b[1;31m# Lifting succeeded, so variables are initialized and we can run the\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 631\u001b[0m \u001b[1;31m# stateless function.\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 632\u001b[1;33m \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_stateless_fn\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m*\u001b[0m\u001b[0margs\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m**\u001b[0m\u001b[0mkwds\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 633\u001b[0m \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 634\u001b[0m \u001b[0mcanon_args\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mcanon_kwds\u001b[0m \u001b[1;33m=\u001b[0m\u001b[0;31m \u001b[0m\u001b[0;31m\\\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;32mC:\\ProgramData\\Anaconda3\\lib\\site-packages\\tensorflow_core\\python\\eager\\function.py\u001b[0m in \u001b[0;36m__call__\u001b[1;34m(self, *args, **kwargs)\u001b[0m\n\u001b[0;32m 2361\u001b[0m \u001b[1;32mwith\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_lock\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 2362\u001b[0m \u001b[0mgraph_function\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0margs\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mkwargs\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_maybe_define_function\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0margs\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mkwargs\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 2363\u001b[1;33m \u001b[1;32mreturn\u001b[0m \u001b[0mgraph_function\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_filtered_call\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0margs\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mkwargs\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;31m# pylint: disable=protected-access\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 2364\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 2365\u001b[0m \u001b[1;33m@\u001b[0m\u001b[0mproperty\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;32mC:\\ProgramData\\Anaconda3\\lib\\site-packages\\tensorflow_core\\python\\eager\\function.py\u001b[0m in \u001b[0;36m_filtered_call\u001b[1;34m(self, args, kwargs)\u001b[0m\n\u001b[0;32m 1609\u001b[0m if isinstance(t, (ops.Tensor,\n\u001b[0;32m 1610\u001b[0m resource_variable_ops.BaseResourceVariable))),\n\u001b[1;32m-> 1611\u001b[1;33m self.captured_inputs)\n\u001b[0m\u001b[0;32m 1612\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 1613\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0m_call_flat\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0margs\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mcaptured_inputs\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mcancellation_manager\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;32mNone\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;32mC:\\ProgramData\\Anaconda3\\lib\\site-packages\\tensorflow_core\\python\\eager\\function.py\u001b[0m in \u001b[0;36m_call_flat\u001b[1;34m(self, args, captured_inputs, cancellation_manager)\u001b[0m\n\u001b[0;32m 1690\u001b[0m \u001b[1;31m# No tape is watching; skip to running the function.\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 1691\u001b[0m return self._build_call_outputs(self._inference_function.call(\n\u001b[1;32m-> 1692\u001b[1;33m ctx, args, cancellation_manager=cancellation_manager))\n\u001b[0m\u001b[0;32m 1693\u001b[0m forward_backward = self._select_forward_and_backward_functions(\n\u001b[0;32m 1694\u001b[0m \u001b[0margs\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;32mC:\\ProgramData\\Anaconda3\\lib\\site-packages\\tensorflow_core\\python\\eager\\function.py\u001b[0m in \u001b[0;36mcall\u001b[1;34m(self, ctx, args, cancellation_manager)\u001b[0m\n\u001b[0;32m 543\u001b[0m \u001b[0minputs\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0margs\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 544\u001b[0m \u001b[0mattrs\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"executor_type\"\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mexecutor_type\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m\"config_proto\"\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mconfig\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 545\u001b[1;33m ctx=ctx)\n\u001b[0m\u001b[0;32m 546\u001b[0m \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 547\u001b[0m outputs = execute.execute_with_cancellation(\n",
"\u001b[1;32mC:\\ProgramData\\Anaconda3\\lib\\site-packages\\tensorflow_core\\python\\eager\\execute.py\u001b[0m in \u001b[0;36mquick_execute\u001b[1;34m(op_name, num_outputs, inputs, attrs, ctx, name)\u001b[0m\n\u001b[0;32m 65\u001b[0m \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 66\u001b[0m \u001b[0mmessage\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0me\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mmessage\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 67\u001b[1;33m \u001b[0msix\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mraise_from\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mcore\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_status_to_exception\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0me\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mcode\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mmessage\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;32mNone\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 68\u001b[0m \u001b[1;32mexcept\u001b[0m \u001b[0mTypeError\u001b[0m \u001b[1;32mas\u001b[0m \u001b[0me\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 69\u001b[0m keras_symbolic_tensors = [\n",
"\u001b[1;32m~\\AppData\\Roaming\\Python\\Python37\\site-packages\\six.py\u001b[0m in \u001b[0;36mraise_from\u001b[1;34m(value, from_value)\u001b[0m\n",
"\u001b[1;31mInvalidArgumentError\u001b[0m: indices[54,195] = 8646 is not in [0, 5002)\n\t [[node sequential_6/embedding_6/embedding_lookup (defined at <ipython-input-44-4c2962189ab4>:16) ]] [Op:__inference_distributed_function_13289]\n\nErrors may have originated from an input operation.\nInput Source operations connected to node sequential_6/embedding_6/embedding_lookup:\n sequential_6/embedding_6/embedding_lookup/12144 (defined at C:\\ProgramData\\Anaconda3\\lib\\contextlib.py:112)\n\nFunction call stack:\ndistributed_function\n"
]
}
],
"source": [
"model = Sequential()\n",
"model.add(Embedding(5002, 120))\n",
"model.add(LSTM(120))\n",
"model.add(Dense(2, activation='sigmoid'))\n",
"\n",
"es = EarlyStopping(monitor='val_loss', mode='min', verbose=1, patience=4)\n",
"mc = ModelCheckpoint('best_model.h5', monitor='val_acc', mode='max', verbose=1, save_best_only=True)\n",
"\n",
"FS_X_train = np.array(FS_X_train)\n",
"FS_X_test = np.array(FS_X_test)\n",
"FS_Y_train = np.array(FS_Y_train)\n",
"FS_Y_test = np.array(FS_Y_test)\n",
"\n",
"\n",
"model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['acc'])\n",
"model.fit(FS_X_train, FS_Y_train, validation_data=(FS_X_test, FS_Y_test), epochs=3, batch_size=64, callbacks=[es, mc])"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# 위에서 실행한 베스트 모델로 뮤지컬 예측값 확인하기"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 드라마 VS 역사"
]
},
{
"cell_type": "code",
"execution_count": 45,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"줄거리 최대 길이 : 1389\n",
"줄거리 평균 길이 : 258.6014285714286\n"
]
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAX0AAAD4CAYAAAAAczaOAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjMsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+AADFEAAAYfUlEQVR4nO3df3Dc9Z3f8ecL+VftlmDHhlLZjnwXNyfH0+YYjaGNphPFxw9DGvNHaBGdxIfV8dyU6K5NModTzdTXpOr4uE5zxlzpuJGKuQlymPQCnsKd48EKGf0BRSQ5IqykVjkDOjgssMNlwMa/3v1jvzIreyXtL+13td/XY2Zn9/vZz+6+v2Pvez/6fD8/FBGYmVk2XJV2AGZmVjtO+mZmGeKkb2aWIU76ZmYZ4qRvZpYhC9IOYCYrV66MlpaWtMOwBvbiiy++HRGrav25/r9tc2mm/9d1nfRbWloYHh5OOwxrYJJeTeNz/X/b5tJM/6/dvWNmliFO+mZmGeKkb2aWIU76ZmYZMmvSl9Qv6YSkkQLPfU1SSFqZHEvSg5LGJL0k6Ya8utskHUtu26p7GmZmVoxiWvqPALddXihpDXAz8Fpe8RZgfXLbATyc1F0B7AJu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gDXRcSbAMn9tUn5fDi/UmOfD+dUkMfpm6WvqGUc6synI+INSdcChyX9fIa68/H8Jk0X+7w9J7f0zdI375ZxiIg3kvsTwPfJdVG9Ndltk9yfSKrPh/MrNfb5cE4FOembpW9eLeMgaZmkvzf5GLgFGCEX8+Qolm3Ak8njg8CXkpEwNwHvTnal1JFSYz8E3CJpeXIB95akrO65e6cBSBoAPgOslDQO7IqIvnSjsmLNw72jrwO+LwlyOeSxiPgLSS8Aj0vqAl4D7krqPw3cDowB7wP31j7kDxX6vgC7KSH2iDgp6ZvkfrABvhER82IwhZdhMDPLEHfvmJlliJO+mVmGOOmbmWWIk76ZWYY46ZuZZYiTvplZhjjpm5llyP8H/eAjQD6Gd5wAAAAASUVORK5CYII=\n",
"text/plain": [
"<Figure size 432x288 with 2 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"\n",
"DH_X_train = []\n",
"DH_Y_train = [] \n",
"\n",
"DHtrain_data_size = 1400//2\n",
"\n",
"for i in range(DHtrain_data_size):\n",
" DH_X_train.append(DR_encoded[i])\n",
" DH_Y_train.append([1,0])\n",
" DH_X_train.append(HS_encoded[i])\n",
" DH_Y_train.append([0,1])\n",
" \n",
"import matplotlib.pyplot as plt\n",
"%matplotlib inline\n",
"\n",
"len_result = [len(s) for s in DH_X_train]\n",
"print(\"줄거리 최대 길이 : \",max(len_result))\n",
"print(\"줄거리 평균 길이 : \",sum(len_result)/len(len_result))\n",
"\n",
"plt.subplot(1,2,1)\n",
"plt.boxplot(len_result)\n",
"plt.subplot(1,2,2)\n",
"plt.hist(len_result, bins=50)\n",
"plt.show()\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 46,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"줄거리 최대 길이 : 1880\n",
"줄거리 평균 길이 : 183.68142857142857\n"
]
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAX0AAAD4CAYAAAAAczaOA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ql0598b+ACwDXgxPc5O5SK3YMxLwPNAXYniGPA7PJYYgBvJXUTtBb4wATH9fXrP58gl77kF9ZtTTC8Any73ZzvY5mkYzMwyxN07ZmYZ4qRvZpYhTvpmZhnipG9mliFO+mZmGeKkb2aWIU76ZmYZ8v8BvNZYS6tJWloAAAAASUVORK5CYII=\n",
"text/plain": [
"<Figure size 432x288 with 2 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"DH_X_test = []\n",
"DH_Y_test = [] \n",
"\n",
"for i in range(DHtrain_data_size):\n",
" DH_X_test.append(DR_encoded[DHtrain_data_size+i])\n",
" DH_Y_test.append([1,0])\n",
" DH_X_test.append(HS_encoded[DHtrain_data_size+i])\n",
" DH_Y_test.append([0,1])\n",
"\n",
"import matplotlib.pyplot as plt\n",
"%matplotlib inline\n",
"\n",
"len_result = [len(s) for s in DH_X_test]\n",
"print(\"줄거리 최대 길이 : \",max(len_result))\n",
"print(\"줄거리 평균 길이 : \",sum(len_result)/len(len_result))\n",
"\n",
"plt.subplot(1,2,1)\n",
"plt.boxplot(len_result)\n",
"plt.subplot(1,2,2)\n",
"plt.hist(len_result, bins=50)\n",
"plt.show()\n"
]
},
{
"cell_type": "code",
"execution_count": 49,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Train on 1400 samples, validate on 1400 samples\n",
"Epoch 1/3\n",
" 64/1400 [>.............................] - ETA: 31sWARNING:tensorflow:Early stopping conditioned on metric `val_loss` which is not available. Available metrics are: \n",
"WARNING:tensorflow:Can save best model only with val_acc available, skipping.\n"
]
},
{
"ename": "InvalidArgumentError",
"evalue": " indices[46,167] = 15001 is not in [0, 5002)\n\t [[node sequential_9/embedding_9/embedding_lookup (defined at <ipython-input-49-edff8fe77726>:22) ]] [Op:__inference_distributed_function_17701]\n\nErrors may have originated from an input operation.\nInput Source operations connected to node sequential_9/embedding_9/embedding_lookup:\n sequential_9/embedding_9/embedding_lookup/16556 (defined at C:\\ProgramData\\Anaconda3\\lib\\contextlib.py:112)\n\nFunction call stack:\ndistributed_function\n",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mInvalidArgumentError\u001b[0m Traceback (most recent call last)",
"\u001b[1;32m<ipython-input-49-edff8fe77726>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m 20\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 21\u001b[0m \u001b[0mmodel\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mcompile\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mloss\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;34m'binary_crossentropy'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0moptimizer\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;34m'adam'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mmetrics\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m'acc'\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 22\u001b[1;33m \u001b[0mmodel\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mfit\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mDH_X_train\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mDH_Y_train\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mvalidation_data\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mDH_X_test\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mDH_Y_test\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mepochs\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;36m3\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mbatch_size\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;36m64\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mcallbacks\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mes\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mmc\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[1;32mC:\\ProgramData\\Anaconda3\\lib\\site-packages\\tensorflow_core\\python\\keras\\engine\\training.py\u001b[0m in \u001b[0;36mfit\u001b[1;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_freq, max_queue_size, workers, use_multiprocessing, **kwargs)\u001b[0m\n\u001b[0;32m 817\u001b[0m \u001b[0mmax_queue_size\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mmax_queue_size\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 818\u001b[0m \u001b[0mworkers\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mworkers\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 819\u001b[1;33m use_multiprocessing=use_multiprocessing)\n\u001b[0m\u001b[0;32m 820\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 821\u001b[0m def evaluate(self,\n",
"\u001b[1;32mC:\\ProgramData\\Anaconda3\\lib\\site-packages\\tensorflow_core\\python\\keras\\engine\\training_v2.py\u001b[0m in \u001b[0;36mfit\u001b[1;34m(self, model, x, y, batch_size, epochs, verbose, callbacks, validation_split, validation_data, shuffle, class_weight, sample_weight, initial_epoch, steps_per_epoch, validation_steps, validation_freq, max_queue_size, workers, use_multiprocessing, **kwargs)\u001b[0m\n\u001b[0;32m 340\u001b[0m \u001b[0mmode\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mModeKeys\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mTRAIN\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 341\u001b[0m \u001b[0mtraining_context\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mtraining_context\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 342\u001b[1;33m total_epochs=epochs)\n\u001b[0m\u001b[0;32m 343\u001b[0m \u001b[0mcbks\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mmake_logs\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mmodel\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mepoch_logs\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mtraining_result\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mModeKeys\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mTRAIN\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 344\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;32mC:\\ProgramData\\Anaconda3\\lib\\site-packages\\tensorflow_core\\python\\keras\\engine\\training_v2.py\u001b[0m in \u001b[0;36mrun_one_epoch\u001b[1;34m(model, iterator, execution_function, dataset_size, batch_size, strategy, steps_per_epoch, num_samples, mode, training_context, total_epochs)\u001b[0m\n\u001b[0;32m 126\u001b[0m step=step, mode=mode, size=current_batch_size) as batch_logs:\n\u001b[0;32m 127\u001b[0m \u001b[1;32mtry\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 128\u001b[1;33m \u001b[0mbatch_outs\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mexecution_function\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0miterator\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 129\u001b[0m \u001b[1;32mexcept\u001b[0m \u001b[1;33m(\u001b[0m\u001b[0mStopIteration\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0merrors\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mOutOfRangeError\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 130\u001b[0m \u001b[1;31m# TODO(kaftan): File bug about tf function and errors.OutOfRangeError?\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;32mC:\\ProgramData\\Anaconda3\\lib\\site-packages\\tensorflow_core\\python\\keras\\engine\\training_v2_utils.py\u001b[0m in \u001b[0;36mexecution_function\u001b[1;34m(input_fn)\u001b[0m\n\u001b[0;32m 96\u001b[0m \u001b[1;31m# `numpy` translates Tensors to values in Eager mode.\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 97\u001b[0m return nest.map_structure(_non_none_constant_value,\n\u001b[1;32m---> 98\u001b[1;33m distributed_function(input_fn))\n\u001b[0m\u001b[0;32m 99\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 100\u001b[0m \u001b[1;32mreturn\u001b[0m \u001b[0mexecution_function\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;32mC:\\ProgramData\\Anaconda3\\lib\\site-packages\\tensorflow_core\\python\\eager\\def_function.py\u001b[0m in \u001b[0;36m__call__\u001b[1;34m(self, *args, **kwds)\u001b[0m\n\u001b[0;32m 566\u001b[0m \u001b[0mxla_context\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mExit\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 567\u001b[0m \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 568\u001b[1;33m \u001b[0mresult\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_call\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m*\u001b[0m\u001b[0margs\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m**\u001b[0m\u001b[0mkwds\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 569\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 570\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0mtracing_count\u001b[0m \u001b[1;33m==\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_get_tracing_count\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;32mC:\\ProgramData\\Anaconda3\\lib\\site-packages\\tensorflow_core\\python\\eager\\def_function.py\u001b[0m in \u001b[0;36m_call\u001b[1;34m(self, *args, **kwds)\u001b[0m\n\u001b[0;32m 630\u001b[0m \u001b[1;31m# Lifting succeeded, so variables are initialized and we can run the\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 631\u001b[0m \u001b[1;31m# stateless function.\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 632\u001b[1;33m \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_stateless_fn\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m*\u001b[0m\u001b[0margs\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m**\u001b[0m\u001b[0mkwds\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 633\u001b[0m \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 634\u001b[0m \u001b[0mcanon_args\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mcanon_kwds\u001b[0m \u001b[1;33m=\u001b[0m\u001b[0;31m \u001b[0m\u001b[0;31m\\\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;32mC:\\ProgramData\\Anaconda3\\lib\\site-packages\\tensorflow_core\\python\\eager\\function.py\u001b[0m in \u001b[0;36m__call__\u001b[1;34m(self, *args, **kwargs)\u001b[0m\n\u001b[0;32m 2361\u001b[0m \u001b[1;32mwith\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_lock\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 2362\u001b[0m \u001b[0mgraph_function\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0margs\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mkwargs\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_maybe_define_function\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0margs\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mkwargs\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 2363\u001b[1;33m \u001b[1;32mreturn\u001b[0m \u001b[0mgraph_function\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_filtered_call\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0margs\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mkwargs\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;31m# pylint: disable=protected-access\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 2364\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 2365\u001b[0m \u001b[1;33m@\u001b[0m\u001b[0mproperty\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;32mC:\\ProgramData\\Anaconda3\\lib\\site-packages\\tensorflow_core\\python\\eager\\function.py\u001b[0m in \u001b[0;36m_filtered_call\u001b[1;34m(self, args, kwargs)\u001b[0m\n\u001b[0;32m 1609\u001b[0m if isinstance(t, (ops.Tensor,\n\u001b[0;32m 1610\u001b[0m resource_variable_ops.BaseResourceVariable))),\n\u001b[1;32m-> 1611\u001b[1;33m self.captured_inputs)\n\u001b[0m\u001b[0;32m 1612\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 1613\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0m_call_flat\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0margs\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mcaptured_inputs\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mcancellation_manager\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;32mNone\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;32mC:\\ProgramData\\Anaconda3\\lib\\site-packages\\tensorflow_core\\python\\eager\\function.py\u001b[0m in \u001b[0;36m_call_flat\u001b[1;34m(self, args, captured_inputs, cancellation_manager)\u001b[0m\n\u001b[0;32m 1690\u001b[0m \u001b[1;31m# No tape is watching; skip to running the function.\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 1691\u001b[0m return self._build_call_outputs(self._inference_function.call(\n\u001b[1;32m-> 1692\u001b[1;33m ctx, args, cancellation_manager=cancellation_manager))\n\u001b[0m\u001b[0;32m 1693\u001b[0m forward_backward = self._select_forward_and_backward_functions(\n\u001b[0;32m 1694\u001b[0m \u001b[0margs\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;32mC:\\ProgramData\\Anaconda3\\lib\\site-packages\\tensorflow_core\\python\\eager\\function.py\u001b[0m in \u001b[0;36mcall\u001b[1;34m(self, ctx, args, cancellation_manager)\u001b[0m\n\u001b[0;32m 543\u001b[0m \u001b[0minputs\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0margs\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 544\u001b[0m \u001b[0mattrs\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"executor_type\"\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mexecutor_type\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m\"config_proto\"\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mconfig\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 545\u001b[1;33m ctx=ctx)\n\u001b[0m\u001b[0;32m 546\u001b[0m \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 547\u001b[0m outputs = execute.execute_with_cancellation(\n",
"\u001b[1;32mC:\\ProgramData\\Anaconda3\\lib\\site-packages\\tensorflow_core\\python\\eager\\execute.py\u001b[0m in \u001b[0;36mquick_execute\u001b[1;34m(op_name, num_outputs, inputs, attrs, ctx, name)\u001b[0m\n\u001b[0;32m 65\u001b[0m \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 66\u001b[0m \u001b[0mmessage\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0me\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mmessage\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 67\u001b[1;33m \u001b[0msix\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mraise_from\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mcore\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_status_to_exception\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0me\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mcode\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mmessage\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;32mNone\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 68\u001b[0m \u001b[1;32mexcept\u001b[0m \u001b[0mTypeError\u001b[0m \u001b[1;32mas\u001b[0m \u001b[0me\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 69\u001b[0m keras_symbolic_tensors = [\n",
"\u001b[1;32m~\\AppData\\Roaming\\Python\\Python37\\site-packages\\six.py\u001b[0m in \u001b[0;36mraise_from\u001b[1;34m(value, from_value)\u001b[0m\n",
"\u001b[1;31mInvalidArgumentError\u001b[0m: indices[46,167] = 15001 is not in [0, 5002)\n\t [[node sequential_9/embedding_9/embedding_lookup (defined at <ipython-input-49-edff8fe77726>:22) ]] [Op:__inference_distributed_function_17701]\n\nErrors may have originated from an input operation.\nInput Source operations connected to node sequential_9/embedding_9/embedding_lookup:\n sequential_9/embedding_9/embedding_lookup/16556 (defined at C:\\ProgramData\\Anaconda3\\lib\\contextlib.py:112)\n\nFunction call stack:\ndistributed_function\n"
]
}
],
"source": [
"max_len = 200\n",
"\n",
"DH_X_train = pad_sequences(DH_X_train, maxlen=max_len)\n",
"DH_X_test = pad_sequences(DH_X_test, maxlen=max_len)\n",
"\n",
"\n",
"model = Sequential()\n",
"model.add(Embedding(5002, 120))\n",
"model.add(LSTM(120))\n",
"model.add(Dense(2, activation='sigmoid'))\n",
"\n",
"es = EarlyStopping(monitor='val_loss', mode='min', verbose=1, patience=4)\n",
"mc = ModelCheckpoint('best_model.h5', monitor='val_acc', mode='max', verbose=1, save_best_only=True)\n",
"\n",
"DH_X_train = np.array(DH_X_train)\n",
"DH_X_test = np.array(DH_X_test)\n",
"DH_Y_train = np.array(DH_Y_train)\n",
"DH_Y_test = np.array(DH_Y_test)\n",
"\n",
"\n",
"model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['acc'])\n",
"model.fit(DH_X_train, DH_Y_train, validation_data=(DH_X_test, DH_Y_test), epochs=3, batch_size=64, callbacks=[es, mc])"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"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.6"
}
},
"nbformat": 4,
"nbformat_minor": 2
}