Teaching Computers to Learn•Interactive notebook lesson•Free
pad sequences
No account is required. Learn the material, try the examples, and mark it complete when you are ready to move on. Sign in with email only if you want to save progress across devices.
Codepython
import tensorflow as tf
import matplotlib.pyplot as plt
import numpy as npOutput
2026-03-24 07:35:19.261072: I tensorflow/core/util/port.cc:113] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`.
2026-03-24 07:35:19.284273: E external/local_xla/xla/stream_executor/cuda/cuda_dnn.cc:9261] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered
2026-03-24 07:35:19.284290: E external/local_xla/xla/stream_executor/cuda/cuda_fft.cc:607] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has already been registered
2026-03-24 07:35:19.284907: E external/local_xla/xla/stream_executor/cuda/cuda_blas.cc:1515] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered
2026-03-24 07:35:19.288790: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX2 AVX_VNNI FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
2026-03-24 07:35:19.723261: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT
Codepython
vocab_size = 10000
(train_data, train_labels), (test_data, test_labels) = tf.keras.datasets.imdb.load_data(num_words=vocab_size)
print("Training samples:", len(train_data))
print("Test samples:", len(test_data))
Output
Training samples: 25000
Test samples: 25000
Codepython
print(train_data[0][:20])Output
[1, 14, 22, 16, 43, 530, 973, 1622, 1385, 65, 458, 4468, 66, 3941, 4, 173, 36, 256, 5, 25]
Codepython
word_index = tf.keras.datasets.imdb.get_word_index()
word_indexOutput
{'fawn': 34701,
'tsukino': 52006,
'nunnery': 52007,
'sonja': 16816,
'vani': 63951,
'woods': 1408,
'spiders': 16115,
'hanging': 2345,
'woody': 2289,
'trawling': 52008,
"hold's": 52009,
'comically': 11307,
'localized': 40830,
'disobeying': 30568,
"'royale": 52010,
"harpo's": 40831,
'canet': 52011,
'aileen': 19313,
'acurately': 52012,
"diplomat's": 52013,
'rickman': 25242,
'arranged': 6746,
'rumbustious': 52014,
'familiarness': 52015,
"spider'": 52016,
'hahahah': 68804,
"wood'": 52017,
'transvestism': 40833,
"hangin'": 34702,
'bringing': 2338,
'seamier': 40834,
'wooded': 34703,
'bravora': 52018,
'grueling': 16817,
'wooden': 1636,
'wednesday': 16818,
"'prix": 52019,
'altagracia': 34704,
'circuitry': 52020,
'crotch': 11585,
'busybody': 57766,
"tart'n'tangy": 52021,
'burgade': 14129,
'thrace': 52023,
"tom's": 11038,
'snuggles': 52025,
'francesco': 29114,
'complainers': 52027,
'templarios': 52125,
'272': 40835,
'273': 52028,
'zaniacs': 52130,
'275': 34706,
'consenting': 27631,
'snuggled': 40836,
'inanimate': 15492,
'uality': 52030,
'bronte': 11926,
'errors': 4010,
'dialogs': 3230,
"yomada's": 52031,
"madman's": 34707,
'dialoge': 30585,
'usenet': 52033,
'videodrome': 40837,
"kid'": 26338,
'pawed': 52034,
"'girlfriend'": 30569,
"'pleasure": 52035,
"'reloaded'": 52036,
"kazakos'": 40839,
'rocque': 52037,
'mailings': 52038,
'brainwashed': 11927,
'mcanally': 16819,
"tom''": 52039,
'kurupt': 25243,
'affiliated': 21905,
'babaganoosh': 52040,
"noe's": 40840,
'quart': 40841,
'kids': 359,
'uplifting': 5034,
'controversy': 7093,
'kida': 21906,
'kidd': 23379,
"error'": 52041,
'neurologist': 52042,
'spotty': 18510,
'cobblers': 30570,
'projection': 9878,
'fastforwarding': 40842,
'sters': 52043,
"eggar's": 52044,
'etherything': 52045,
'gateshead': 40843,
'airball': 34708,
'unsinkable': 25244,
'stern': 7180,
"cervi's": 52046,
'dnd': 40844,
'dna': 11586,
'insecurity': 20598,
"'reboot'": 52047,
'trelkovsky': 11037,
'jaekel': 52048,
'sidebars': 52049,
"sforza's": 52050,
'distortions': 17633,
'mutinies': 52051,
'sermons': 30602,
'7ft': 40846,
'boobage': 52052,
"o'bannon's": 52053,
'populations': 23380,
'chulak': 52054,
'mesmerize': 27633,
'quinnell': 52055,
'yahoo': 10307,
'meteorologist': 52057,
'beswick': 42577,
'boorman': 15493,
'voicework': 40847,
"ster'": 52058,
'blustering': 22922,
'hj': 52059,
'intake': 27634,
'morally': 5621,
'jumbling': 40849,
'bowersock': 52060,
"'porky's'": 52061,
'gershon': 16821,
'ludicrosity': 40850,
'coprophilia': 52062,
'expressively': 40851,
"india's": 19500,
"post's": 34710,
'wana': 52063,
'wang': 5283,
'wand': 30571,
'wane': 25245,
'edgeways': 52321,
'titanium': 34711,
'pinta': 40852,
'want': 178,
'pinto': 30572,
'whoopdedoodles': 52065,
'tchaikovsky': 21908,
'travel': 2103,
"'victory'": 52066,
'copious': 11928,
'gouge': 22433,
"chapters'": 52067,
'barbra': 6702,
'uselessness': 30573,
"wan'": 52068,
'assimilated': 27635,
'petiot': 16116,
'most\x85and': 52069,
'dinosaurs': 3930,
'wrong': 352,
'seda': 52070,
'stollen': 52071,
'sentencing': 34712,
'ouroboros': 40853,
'assimilates': 40854,
'colorfully': 40855,
'glenne': 27636,
'dongen': 52072,
'subplots': 4760,
'kiloton': 52073,
'chandon': 23381,
"effect'": 34713,
'snugly': 27637,
'kuei': 40856,
'welcomed': 9092,
'dishonor': 30071,
'concurrence': 52075,
'stoicism': 23382,
"guys'": 14896,
"beroemd'": 52077,
'butcher': 6703,
"melfi's": 40857,
'aargh': 30623,
'playhouse': 20599,
'wickedly': 11308,
'fit': 1180,
'labratory': 52078,
'lifeline': 40859,
'screaming': 1927,
'fix': 4287,
'cineliterate': 52079,
'fic': 52080,
'fia': 52081,
'fig': 34714,
'fmvs': 52082,
'fie': 52083,
'reentered': 52084,
'fin': 30574,
'doctresses': 52085,
'fil': 52086,
'zucker': 12606,
'ached': 31931,
'counsil': 52088,
'paterfamilias': 52089,
'songwriter': 13885,
'shivam': 34715,
'hurting': 9654,
'effects': 299,
'slauther': 52090,
"'flame'": 52091,
'sommerset': 52092,
'interwhined': 52093,
'whacking': 27638,
'bartok': 52094,
'barton': 8775,
'frewer': 21909,
"fi'": 52095,
'ingrid': 6192,
'stribor': 30575,
'approporiately': 52096,
'wobblyhand': 52097,
'tantalisingly': 52098,
'ankylosaurus': 52099,
'parasites': 17634,
'childen': 52100,
"jenkins'": 52101,
'metafiction': 52102,
'golem': 17635,
'indiscretion': 40860,
"reeves'": 23383,
"inamorata's": 57781,
'brittannica': 52104,
'adapt': 7916,
"russo's": 30576,
'guitarists': 48246,
'abbott': 10553,
'abbots': 40861,
'lanisha': 17649,
'magickal': 40863,
'mattter': 52105,
"'willy": 52106,
'pumpkins': 34716,
'stuntpeople': 52107,
'estimate': 30577,
'ugghhh': 40864,
'gameplay': 11309,
"wern't": 52108,
"n'sync": 40865,
'sickeningly': 16117,
'chiara': 40866,
'disturbed': 4011,
'portmanteau': 40867,
'ineffectively': 52109,
"duchonvey's": 82143,
"nasty'": 37519,
'purpose': 1285,
'lazers': 52112,
'lightened': 28105,
'kaliganj': 52113,
'popularism': 52114,
"damme's": 18511,
'stylistics': 30578,
'mindgaming': 52115,
'spoilerish': 46449,
"'corny'": 52117,
'boerner': 34718,
'olds': 6792,
'bakelite': 52118,
'renovated': 27639,
'forrester': 27640,
"lumiere's": 52119,
'gaskets': 52024,
'needed': 884,
'smight': 34719,
'master': 1297,
"edie's": 25905,
'seeber': 40868,
'hiya': 52120,
'fuzziness': 52121,
'genesis': 14897,
'rewards': 12607,
'enthrall': 30579,
"'about": 40869,
"recollection's": 52122,
'mutilated': 11039,
'fatherlands': 52123,
"fischer's": 52124,
'positively': 5399,
'270': 34705,
'ahmed': 34720,
'zatoichi': 9836,
'bannister': 13886,
'anniversaries': 52127,
"helm's": 30580,
"'work'": 52128,
'exclaimed': 34721,
"'unfunny'": 52129,
'274': 52029,
'feeling': 544,
"wanda's": 52131,
'dolan': 33266,
'278': 52133,
'peacoat': 52134,
'brawny': 40870,
'mishra': 40871,
'worlders': 40872,
'protags': 52135,
'skullcap': 52136,
'dastagir': 57596,
'affairs': 5622,
'wholesome': 7799,
'hymen': 52137,
'paramedics': 25246,
'unpersons': 52138,
'heavyarms': 52139,
'affaire': 52140,
'coulisses': 52141,
'hymer': 40873,
'kremlin': 52142,
'shipments': 30581,
'pixilated': 52143,
"'00s": 30582,
'diminishing': 18512,
'cinematic': 1357,
'resonates': 14898,
'simplify': 40874,
"nature'": 40875,
'temptresses': 40876,
'reverence': 16822,
'resonated': 19502,
'dailey': 34722,
'2\x85': 52144,
'treize': 27641,
'majo': 52145,
'kiya': 21910,
'woolnough': 52146,
'thanatos': 39797,
'sandoval': 35731,
'dorama': 40879,
"o'shaughnessy": 52147,
'tech': 4988,
'fugitives': 32018,
'teck': 30583,
"'e'": 76125,
'doesn’t': 40881,
'purged': 52149,
'saying': 657,
"martians'": 41095,
'norliss': 23418,
'dickey': 27642,
'dicker': 52152,
"'sependipity": 52153,
'padded': 8422,
'ordell': 57792,
"sturges'": 40882,
'independentcritics': 52154,
'tempted': 5745,
"atkinson's": 34724,
'hounded': 25247,
'apace': 52155,
'clicked': 15494,
"'humor'": 30584,
"martino's": 17177,
"'supporting": 52156,
'warmongering': 52032,
"zemeckis's": 34725,
'lube': 21911,
'shocky': 52157,
'plate': 7476,
'plata': 40883,
'sturgess': 40884,
"nerds'": 40885,
'plato': 20600,
'plath': 34726,
'platt': 40886,
'mcnab': 52159,
'clumsiness': 27643,
'altogether': 3899,
'massacring': 42584,
'bicenntinial': 52160,
'skaal': 40887,
'droning': 14360,
'lds': 8776,
'jaguar': 21912,
"cale's": 34727,
'nicely': 1777,
'mummy': 4588,
"lot's": 18513,
'patch': 10086,
'kerkhof': 50202,
"leader's": 52161,
"'movie": 27644,
'uncomfirmed': 52162,
'heirloom': 40888,
'wrangle': 47360,
'emotion\x85': 52163,
"'stargate'": 52164,
'pinoy': 40889,
'conchatta': 40890,
'broeke': 41128,
'advisedly': 40891,
"barker's": 17636,
'descours': 52166,
'lots': 772,
'lotr': 9259,
'irs': 9879,
'lott': 52167,
'xvi': 40892,
'irk': 34728,
'irl': 52168,
'ira': 6887,
'belzer': 21913,
'irc': 52169,
'ire': 27645,
'requisites': 40893,
'discipline': 7693,
'lyoko': 52961,
'extend': 11310,
'nature': 873,
"'dickie'": 52170,
'optimist': 40894,
'lapping': 30586,
'superficial': 3900,
'vestment': 52171,
'extent': 2823,
'tendons': 52172,
"heller's": 52173,
'quagmires': 52174,
'miyako': 52175,
'moocow': 20601,
"coles'": 52176,
'lookit': 40895,
'ravenously': 52177,
'levitating': 40896,
'perfunctorily': 52178,
'lookin': 30587,
"lot'": 40898,
'lookie': 52179,
'fearlessly': 34870,
'libyan': 52181,
'fondles': 40899,
'gopher': 35714,
'wearying': 40901,
"nz's": 52182,
'minuses': 27646,
'puposelessly': 52183,
'shandling': 52184,
'decapitates': 31268,
'humming': 11929,
"'nother": 40902,
'smackdown': 21914,
'underdone': 30588,
'frf': 40903,
'triviality': 52185,
'fro': 25248,
'bothers': 8777,
"'kensington": 52186,
'much': 73,
'muco': 34730,
'wiseguy': 22615,
"richie's": 27648,
'tonino': 40904,
'unleavened': 52187,
'fry': 11587,
"'tv'": 40905,
'toning': 40906,
'obese': 14361,
'sensationalized': 30589,
'spiv': 40907,
'spit': 6259,
'arkin': 7364,
'charleton': 21915,
'jeon': 16823,
'boardroom': 21916,
'doubts': 4989,
'spin': 3084,
'hepo': 53083,
'wildcat': 27649,
'venoms': 10584,
'misconstrues': 52191,
'mesmerising': 18514,
'misconstrued': 40908,
'rescinds': 52192,
'prostrate': 52193,
'majid': 40909,
'climbed': 16479,
'canoeing': 34731,
'majin': 52195,
'animie': 57804,
'sylke': 40910,
'conditioned': 14899,
'waddell': 40911,
'3\x85': 52196,
'hyperdrive': 41188,
'conditioner': 34732,
'bricklayer': 53153,
'hong': 2576,
'memoriam': 52198,
'inventively': 30592,
"levant's": 25249,
'portobello': 20638,
'remand': 52200,
'mummified': 19504,
'honk': 27650,
'spews': 19505,
'visitations': 40912,
'mummifies': 52201,
'cavanaugh': 25250,
'zeon': 23385,
"jungle's": 40913,
'viertel': 34733,
'frenchmen': 27651,
'torpedoes': 52202,
'schlessinger': 52203,
'torpedoed': 34734,
'blister': 69876,
'cinefest': 52204,
'furlough': 34735,
'mainsequence': 52205,
'mentors': 40914,
'academic': 9094,
'stillness': 20602,
'academia': 40915,
'lonelier': 52206,
'nibby': 52207,
"losers'": 52208,
'cineastes': 40916,
'corporate': 4449,
'massaging': 40917,
'bellow': 30593,
'absurdities': 19506,
'expetations': 53241,
'nyfiken': 40918,
'mehras': 75638,
'lasse': 52209,
'visability': 52210,
'militarily': 33946,
"elder'": 52211,
'gainsbourg': 19023,
'hah': 20603,
'hai': 13420,
'haj': 34736,
'hak': 25251,
'hal': 4311,
'ham': 4892,
'duffer': 53259,
'haa': 52213,
'had': 66,
'advancement': 11930,
'hag': 16825,
"hand'": 25252,
'hay': 13421,
'mcnamara': 20604,
"mozart's": 52214,
'duffel': 30731,
'haq': 30594,
'har': 13887,
'has': 44,
'hat': 2401,
'hav': 40919,
'haw': 30595,
'figtings': 52215,
'elders': 15495,
'underpanted': 52216,
'pninson': 52217,
'unequivocally': 27652,
"barbara's": 23673,
"bello'": 52219,
'indicative': 12997,
'yawnfest': 40920,
'hexploitation': 52220,
"loder's": 52221,
'sleuthing': 27653,
"justin's": 32622,
"'ball": 52222,
"'summer": 52223,
"'demons'": 34935,
"mormon's": 52225,
"laughton's": 34737,
'debell': 52226,
'shipyard': 39724,
'unabashedly': 30597,
'disks': 40401,
'crowd': 2290,
'crowe': 10087,
"vancouver's": 56434,
'mosques': 34738,
'crown': 6627,
'culpas': 52227,
'crows': 27654,
'surrell': 53344,
'flowless': 52229,
'sheirk': 52230,
"'three": 40923,
"peterson'": 52231,
'ooverall': 52232,
'perchance': 40924,
'bottom': 1321,
'chabert': 53363,
'sneha': 52233,
'inhuman': 13888,
'ichii': 52234,
'ursla': 52235,
'completly': 30598,
'moviedom': 40925,
'raddick': 52236,
'brundage': 51995,
'brigades': 40926,
'starring': 1181,
"'goal'": 52237,
'caskets': 52238,
'willcock': 52239,
"threesome's": 52240,
"mosque'": 52241,
"cover's": 52242,
'spaceships': 17637,
'anomalous': 40927,
'ptsd': 27655,
'shirdan': 52243,
'obscenity': 21962,
'lemmings': 30599,
'duccio': 30600,
"levene's": 52244,
"'gorby'": 52245,
"teenager's": 25255,
'marshall': 5340,
'honeymoon': 9095,
'shoots': 3231,
'despised': 12258,
'okabasho': 52246,
'fabric': 8289,
'cannavale': 18515,
'raped': 3537,
"tutt's": 52247,
'grasping': 17638,
'despises': 18516,
"thief's": 40928,
'rapes': 8926,
'raper': 52248,
"eyre'": 27656,
'walchek': 52249,
"elmo's": 23386,
'perfumes': 40929,
'spurting': 21918,
"exposition'\x85": 52250,
'denoting': 52251,
'thesaurus': 34740,
"shoot'": 40930,
'bonejack': 49759,
'simpsonian': 52253,
'hebetude': 30601,
"hallow's": 34741,
'desperation\x85': 52254,
'incinerator': 34742,
'congratulations': 10308,
'humbled': 52255,
"else's": 5924,
'trelkovski': 40845,
"rape'": 52256,
"'chapters'": 59386,
'1600s': 52257,
'martian': 7253,
'nicest': 25256,
'eyred': 52259,
'passenger': 9457,
'disgrace': 6041,
'moderne': 52260,
'barrymore': 5120,
'yankovich': 52261,
'moderns': 40931,
'studliest': 52262,
'bedsheet': 52263,
'decapitation': 14900,
'slurring': 52264,
"'nunsploitation'": 52265,
"'character'": 34743,
'cambodia': 9880,
'rebelious': 52266,
'pasadena': 27657,
'crowne': 40932,
"'bedchamber": 52267,
'conjectural': 52268,
'appologize': 52269,
'halfassing': 52270,
'paycheque': 57816,
'palms': 20606,
"'islands": 52271,
'hawked': 40933,
'palme': 21919,
'conservatively': 40934,
'larp': 64007,
'palma': 5558,
'smelling': 21920,
'aragorn': 12998,
'hawker': 52272,
'hawkes': 52273,
'explosions': 3975,
'loren': 8059,
"pyle's": 52274,
'shootout': 6704,
"mike's": 18517,
"driscoll's": 52275,
'cogsworth': 40935,
"britian's": 52276,
'childs': 34744,
"portrait's": 52277,
'chain': 3626,
'whoever': 2497,
'puttered': 52278,
'childe': 52279,
'maywether': 52280,
'chair': 3036,
"rance's": 52281,
'machu': 34745,
'ballet': 4517,
'grapples': 34746,
'summerize': 76152,
'freelance': 30603,
"andrea's": 52283,
'\x91very': 52284,
'coolidge': 45879,
'mache': 18518,
'balled': 52285,
'grappled': 40937,
'macha': 18519,
'underlining': 21921,
'macho': 5623,
'oversight': 19507,
'machi': 25257,
'verbally': 11311,
'tenacious': 21922,
'windshields': 40938,
'paychecks': 18557,
'jerk': 3396,
"good'": 11931,
'prancer': 34748,
'prances': 21923,
'olympus': 52286,
'lark': 21924,
'embark': 10785,
'gloomy': 7365,
'jehaan': 52287,
'turaqui': 52288,
"child'": 20607,
'locked': 2894,
'pranced': 52289,
'exact': 2588,
'unattuned': 52290,
'minute': 783,
'skewed': 16118,
'hodgins': 40940,
'skewer': 34749,
'think\x85': 52291,
'rosenstein': 38765,
'helmit': 52292,
'wrestlemanias': 34750,
'hindered': 16826,
"martha's": 30604,
'cheree': 52293,
"pluckin'": 52294,
'ogles': 40941,
'heavyweight': 11932,
'aada': 82190,
'chopping': 11312,
'strongboy': 61534,
'hegemonic': 41342,
'adorns': 40942,
'xxth': 41346,
'nobuhiro': 34751,
'capitães': 52298,
'kavogianni': 52299,
'antwerp': 13422,
'celebrated': 6538,
'roarke': 52300,
'baggins': 40943,
'cheeseburgers': 31270,
'matras': 52301,
"nineties'": 52302,
"'craig'": 52303,
'celebrates': 12999,
'unintentionally': 3383,
'drafted': 14362,
'climby': 52304,
'303': 52305,
'oldies': 18520,
'climbs': 9096,
'honour': 9655,
'plucking': 34752,
'305': 30074,
'address': 5514,
'menjou': 40944,
"'freak'": 42592,
'dwindling': 19508,
'benson': 9458,
'white’s': 52307,
'shamelessness': 40945,
'impacted': 21925,
'upatz': 52308,
'cusack': 3840,
"flavia's": 37567,
'effette': 52309,
'influx': 34753,
'boooooooo': 52310,
'dimitrova': 52311,
'houseman': 13423,
'bigas': 25259,
'boylen': 52312,
'phillipenes': 52313,
'fakery': 40946,
"grandpa's": 27658,
'darnell': 27659,
'undergone': 19509,
'handbags': 52315,
'perished': 21926,
'pooped': 37778,
'vigour': 27660,
'opposed': 3627,
'etude': 52316,
"caine's": 11799,
'doozers': 52317,
'photojournals': 34754,
'perishes': 52318,
'constrains': 34755,
'migenes': 40948,
'consoled': 30605,
'alastair': 16827,
'wvs': 52319,
'ooooooh': 52320,
'approving': 34756,
'consoles': 40949,
'disparagement': 52064,
'futureistic': 52322,
'rebounding': 52323,
"'date": 52324,
'gregoire': 52325,
'rutherford': 21927,
'americanised': 34757,
'novikov': 82196,
'following': 1042,
'munroe': 34758,
"morita'": 52326,
'christenssen': 52327,
'oatmeal': 23106,
'fossey': 25260,
'livered': 40950,
'listens': 13000,
"'marci": 76164,
"otis's": 52330,
'thanking': 23387,
'maude': 16019,
'extensions': 34759,
'ameteurish': 52332,
"commender's": 52333,
'agricultural': 27661,
'convincingly': 4518,
'fueled': 17639,
'mahattan': 54014,
"paris's": 40952,
'vulkan': 52336,
'stapes': 52337,
'odysessy': 52338,
'harmon': 12259,
'surfing': 4252,
'halloran': 23494,
'unbelieveably': 49580,
"'offed'": 52339,
'quadrant': 30607,
'inhabiting': 19510,
'nebbish': 34760,
'forebears': 40953,
'skirmish': 34761,
'ocassionally': 52340,
"'resist": 52341,
'impactful': 21928,
'spicier': 52342,
'touristy': 40954,
"'football'": 52343,
'webpage': 40955,
'exurbia': 52345,
'jucier': 52346,
'professors': 14901,
'structuring': 34762,
'jig': 30608,
'overlord': 40956,
'disconnect': 25261,
'sniffle': 82201,
'slimeball': 40957,
'jia': 40958,
'milked': 16828,
'banjoes': 40959,
'jim': 1237,
'workforces': 52348,
'jip': 52349,
'rotweiller': 52350,
'mundaneness': 34763,
"'ninja'": 52351,
"dead'": 11040,
"cipriani's": 40960,
'modestly': 20608,
"professor'": 52352,
'shacked': 40961,
'bashful': 34764,
'sorter': 23388,
'overpowering': 16120,
'workmanlike': 18521,
'henpecked': 27662,
'sorted': 18522,
"jōb's": 52354,
"'always": 52355,
"'baptists": 34765,
'dreamcatchers': 52356,
"'silence'": 52357,
'hickory': 21929,
'fun\x97yet': 52358,
'breakumentary': 52359,
'didn': 15496,
'didi': 52360,
'pealing': 52361,
'dispite': 40962,
"italy's": 25262,
'instability': 21930,
'quarter': 6539,
'quartet': 12608,
'padmé': 52362,
"'bleedmedry": 52363,
'pahalniuk': 52364,
'honduras': 52365,
'bursting': 10786,
"pablo's": 41465,
'irremediably': 52367,
'presages': 40963,
'bowlegged': 57832,
'dalip': 65183,
'entering': 6260,
'newsradio': 76172,
'presaged': 54150,
"giallo's": 27663,
'bouyant': 40964,
'amerterish': 52368,
'rajni': 18523,
'leeves': 30610,
'macauley': 34767,
'seriously': 612,
'sugercoma': 52369,
'grimstead': 52370,
"'fairy'": 52371,
'zenda': 30611,
"'twins'": 52372,
'realisation': 17640,
'highsmith': 27664,
'raunchy': 7817,
'incentives': 40965,
'flatson': 52374,
'snooker': 35097,
'crazies': 16829,
'crazier': 14902,
'grandma': 7094,
'napunsaktha': 52375,
'workmanship': 30612,
'reisner': 52376,
"sanford's": 61306,
'\x91doña': 52377,
'modest': 6108,
"everything's": 19153,
'hamer': 40966,
"couldn't'": 52379,
'quibble': 13001,
'socking': 52380,
'tingler': 21931,
'gutman': 52381,
'lachlan': 40967,
'tableaus': 52382,
'headbanger': 52383,
'spoken': 2847,
'cerebrally': 34768,
"'road": 23490,
'tableaux': 21932,
"proust's": 40968,
'periodical': 40969,
"shoveller's": 52385,
'tamara': 25263,
'affords': 17641,
'concert': 3249,
"yara's": 87955,
'someome': 52386,
'lingering': 8424,
"abraham's": 41511,
'beesley': 34769,
'cherbourg': 34770,
'kagan': 28624,
'snatch': 9097,
"miyazaki's": 9260,
'absorbs': 25264,
"koltai's": 40970,
'tingled': 64027,
'crossroads': 19511,
'rehab': 16121,
'falworth': 52389,
'sequals': 52390,
...}Codepython
reverse_word_index = {value + 3: key for key, value in word_index.items()}
reverse_word_indexOutput
{34704: 'fawn',
52009: 'tsukino',
52010: 'nunnery',
16819: 'sonja',
63954: 'vani',
1411: 'woods',
16118: 'spiders',
2348: 'hanging',
2292: 'woody',
52011: 'trawling',
52012: "hold's",
11310: 'comically',
40833: 'localized',
30571: 'disobeying',
52013: "'royale",
40834: "harpo's",
52014: 'canet',
19316: 'aileen',
52015: 'acurately',
52016: "diplomat's",
25245: 'rickman',
6749: 'arranged',
52017: 'rumbustious',
52018: 'familiarness',
52019: "spider'",
68807: 'hahahah',
52020: "wood'",
40836: 'transvestism',
34705: "hangin'",
2341: 'bringing',
40837: 'seamier',
34706: 'wooded',
52021: 'bravora',
16820: 'grueling',
1639: 'wooden',
16821: 'wednesday',
52022: "'prix",
34707: 'altagracia',
52023: 'circuitry',
11588: 'crotch',
57769: 'busybody',
52024: "tart'n'tangy",
14132: 'burgade',
52026: 'thrace',
11041: "tom's",
52028: 'snuggles',
29117: 'francesco',
52030: 'complainers',
52128: 'templarios',
40838: '272',
52031: '273',
52133: 'zaniacs',
34709: '275',
27634: 'consenting',
40839: 'snuggled',
15495: 'inanimate',
52033: 'uality',
11929: 'bronte',
4013: 'errors',
3233: 'dialogs',
52034: "yomada's",
34710: "madman's",
30588: 'dialoge',
52036: 'usenet',
40840: 'videodrome',
26341: "kid'",
52037: 'pawed',
30572: "'girlfriend'",
52038: "'pleasure",
52039: "'reloaded'",
40842: "kazakos'",
52040: 'rocque',
52041: 'mailings',
11930: 'brainwashed',
16822: 'mcanally',
52042: "tom''",
25246: 'kurupt',
21908: 'affiliated',
52043: 'babaganoosh',
40843: "noe's",
40844: 'quart',
362: 'kids',
5037: 'uplifting',
7096: 'controversy',
21909: 'kida',
23382: 'kidd',
52044: "error'",
52045: 'neurologist',
18513: 'spotty',
30573: 'cobblers',
9881: 'projection',
40845: 'fastforwarding',
52046: 'sters',
52047: "eggar's",
52048: 'etherything',
40846: 'gateshead',
34711: 'airball',
25247: 'unsinkable',
7183: 'stern',
52049: "cervi's",
40847: 'dnd',
11589: 'dna',
20601: 'insecurity',
52050: "'reboot'",
11040: 'trelkovsky',
52051: 'jaekel',
52052: 'sidebars',
52053: "sforza's",
17636: 'distortions',
52054: 'mutinies',
30605: 'sermons',
40849: '7ft',
52055: 'boobage',
52056: "o'bannon's",
23383: 'populations',
52057: 'chulak',
27636: 'mesmerize',
52058: 'quinnell',
10310: 'yahoo',
52060: 'meteorologist',
42580: 'beswick',
15496: 'boorman',
40850: 'voicework',
52061: "ster'",
22925: 'blustering',
52062: 'hj',
27637: 'intake',
5624: 'morally',
40852: 'jumbling',
52063: 'bowersock',
52064: "'porky's'",
16824: 'gershon',
40853: 'ludicrosity',
52065: 'coprophilia',
40854: 'expressively',
19503: "india's",
34713: "post's",
52066: 'wana',
5286: 'wang',
30574: 'wand',
25248: 'wane',
52324: 'edgeways',
34714: 'titanium',
40855: 'pinta',
181: 'want',
30575: 'pinto',
52068: 'whoopdedoodles',
21911: 'tchaikovsky',
2106: 'travel',
52069: "'victory'",
11931: 'copious',
22436: 'gouge',
52070: "chapters'",
6705: 'barbra',
30576: 'uselessness',
52071: "wan'",
27638: 'assimilated',
16119: 'petiot',
52072: 'most\x85and',
3933: 'dinosaurs',
355: 'wrong',
52073: 'seda',
52074: 'stollen',
34715: 'sentencing',
40856: 'ouroboros',
40857: 'assimilates',
40858: 'colorfully',
27639: 'glenne',
52075: 'dongen',
4763: 'subplots',
52076: 'kiloton',
23384: 'chandon',
34716: "effect'",
27640: 'snugly',
40859: 'kuei',
9095: 'welcomed',
30074: 'dishonor',
52078: 'concurrence',
23385: 'stoicism',
14899: "guys'",
52080: "beroemd'",
6706: 'butcher',
40860: "melfi's",
30626: 'aargh',
20602: 'playhouse',
11311: 'wickedly',
1183: 'fit',
52081: 'labratory',
40862: 'lifeline',
1930: 'screaming',
4290: 'fix',
52082: 'cineliterate',
52083: 'fic',
52084: 'fia',
34717: 'fig',
52085: 'fmvs',
52086: 'fie',
52087: 'reentered',
30577: 'fin',
52088: 'doctresses',
52089: 'fil',
12609: 'zucker',
31934: 'ached',
52091: 'counsil',
52092: 'paterfamilias',
13888: 'songwriter',
34718: 'shivam',
9657: 'hurting',
302: 'effects',
52093: 'slauther',
52094: "'flame'",
52095: 'sommerset',
52096: 'interwhined',
27641: 'whacking',
52097: 'bartok',
8778: 'barton',
21912: 'frewer',
52098: "fi'",
6195: 'ingrid',
30578: 'stribor',
52099: 'approporiately',
52100: 'wobblyhand',
52101: 'tantalisingly',
52102: 'ankylosaurus',
17637: 'parasites',
52103: 'childen',
52104: "jenkins'",
52105: 'metafiction',
17638: 'golem',
40863: 'indiscretion',
23386: "reeves'",
57784: "inamorata's",
52107: 'brittannica',
7919: 'adapt',
30579: "russo's",
48249: 'guitarists',
10556: 'abbott',
40864: 'abbots',
17652: 'lanisha',
40866: 'magickal',
52108: 'mattter',
52109: "'willy",
34719: 'pumpkins',
52110: 'stuntpeople',
30580: 'estimate',
40867: 'ugghhh',
11312: 'gameplay',
52111: "wern't",
40868: "n'sync",
16120: 'sickeningly',
40869: 'chiara',
4014: 'disturbed',
40870: 'portmanteau',
52112: 'ineffectively',
82146: "duchonvey's",
37522: "nasty'",
1288: 'purpose',
52115: 'lazers',
28108: 'lightened',
52116: 'kaliganj',
52117: 'popularism',
18514: "damme's",
30581: 'stylistics',
52118: 'mindgaming',
46452: 'spoilerish',
52120: "'corny'",
34721: 'boerner',
6795: 'olds',
52121: 'bakelite',
27642: 'renovated',
27643: 'forrester',
52122: "lumiere's",
52027: 'gaskets',
887: 'needed',
34722: 'smight',
1300: 'master',
25908: "edie's",
40871: 'seeber',
52123: 'hiya',
52124: 'fuzziness',
14900: 'genesis',
12610: 'rewards',
30582: 'enthrall',
40872: "'about",
52125: "recollection's",
11042: 'mutilated',
52126: 'fatherlands',
52127: "fischer's",
5402: 'positively',
34708: '270',
34723: 'ahmed',
9839: 'zatoichi',
13889: 'bannister',
52130: 'anniversaries',
30583: "helm's",
52131: "'work'",
34724: 'exclaimed',
52132: "'unfunny'",
52032: '274',
547: 'feeling',
52134: "wanda's",
33269: 'dolan',
52136: '278',
52137: 'peacoat',
40873: 'brawny',
40874: 'mishra',
40875: 'worlders',
52138: 'protags',
52139: 'skullcap',
57599: 'dastagir',
5625: 'affairs',
7802: 'wholesome',
52140: 'hymen',
25249: 'paramedics',
52141: 'unpersons',
52142: 'heavyarms',
52143: 'affaire',
52144: 'coulisses',
40876: 'hymer',
52145: 'kremlin',
30584: 'shipments',
52146: 'pixilated',
30585: "'00s",
18515: 'diminishing',
1360: 'cinematic',
14901: 'resonates',
40877: 'simplify',
40878: "nature'",
40879: 'temptresses',
16825: 'reverence',
19505: 'resonated',
34725: 'dailey',
52147: '2\x85',
27644: 'treize',
52148: 'majo',
21913: 'kiya',
52149: 'woolnough',
39800: 'thanatos',
35734: 'sandoval',
40882: 'dorama',
52150: "o'shaughnessy",
4991: 'tech',
32021: 'fugitives',
30586: 'teck',
76128: "'e'",
40884: 'doesn’t',
52152: 'purged',
660: 'saying',
41098: "martians'",
23421: 'norliss',
27645: 'dickey',
52155: 'dicker',
52156: "'sependipity",
8425: 'padded',
57795: 'ordell',
40885: "sturges'",
52157: 'independentcritics',
5748: 'tempted',
34727: "atkinson's",
25250: 'hounded',
52158: 'apace',
15497: 'clicked',
30587: "'humor'",
17180: "martino's",
52159: "'supporting",
52035: 'warmongering',
34728: "zemeckis's",
21914: 'lube',
52160: 'shocky',
7479: 'plate',
40886: 'plata',
40887: 'sturgess',
40888: "nerds'",
20603: 'plato',
34729: 'plath',
40889: 'platt',
52162: 'mcnab',
27646: 'clumsiness',
3902: 'altogether',
42587: 'massacring',
52163: 'bicenntinial',
40890: 'skaal',
14363: 'droning',
8779: 'lds',
21915: 'jaguar',
34730: "cale's",
1780: 'nicely',
4591: 'mummy',
18516: "lot's",
10089: 'patch',
50205: 'kerkhof',
52164: "leader's",
27647: "'movie",
52165: 'uncomfirmed',
40891: 'heirloom',
47363: 'wrangle',
52166: 'emotion\x85',
52167: "'stargate'",
40892: 'pinoy',
40893: 'conchatta',
41131: 'broeke',
40894: 'advisedly',
17639: "barker's",
52169: 'descours',
775: 'lots',
9262: 'lotr',
9882: 'irs',
52170: 'lott',
40895: 'xvi',
34731: 'irk',
52171: 'irl',
6890: 'ira',
21916: 'belzer',
52172: 'irc',
27648: 'ire',
40896: 'requisites',
7696: 'discipline',
52964: 'lyoko',
11313: 'extend',
876: 'nature',
52173: "'dickie'",
40897: 'optimist',
30589: 'lapping',
3903: 'superficial',
52174: 'vestment',
2826: 'extent',
52175: 'tendons',
52176: "heller's",
52177: 'quagmires',
52178: 'miyako',
20604: 'moocow',
52179: "coles'",
40898: 'lookit',
52180: 'ravenously',
40899: 'levitating',
52181: 'perfunctorily',
30590: 'lookin',
40901: "lot'",
52182: 'lookie',
34873: 'fearlessly',
52184: 'libyan',
40902: 'fondles',
35717: 'gopher',
40904: 'wearying',
52185: "nz's",
27649: 'minuses',
52186: 'puposelessly',
52187: 'shandling',
31271: 'decapitates',
11932: 'humming',
40905: "'nother",
21917: 'smackdown',
30591: 'underdone',
40906: 'frf',
52188: 'triviality',
25251: 'fro',
8780: 'bothers',
52189: "'kensington",
76: 'much',
34733: 'muco',
22618: 'wiseguy',
27651: "richie's",
40907: 'tonino',
52190: 'unleavened',
11590: 'fry',
40908: "'tv'",
40909: 'toning',
14364: 'obese',
30592: 'sensationalized',
40910: 'spiv',
6262: 'spit',
7367: 'arkin',
21918: 'charleton',
16826: 'jeon',
21919: 'boardroom',
4992: 'doubts',
3087: 'spin',
53086: 'hepo',
27652: 'wildcat',
10587: 'venoms',
52194: 'misconstrues',
18517: 'mesmerising',
40911: 'misconstrued',
52195: 'rescinds',
52196: 'prostrate',
40912: 'majid',
16482: 'climbed',
34734: 'canoeing',
52198: 'majin',
57807: 'animie',
40913: 'sylke',
14902: 'conditioned',
40914: 'waddell',
52199: '3\x85',
41191: 'hyperdrive',
34735: 'conditioner',
53156: 'bricklayer',
2579: 'hong',
52201: 'memoriam',
30595: 'inventively',
25252: "levant's",
20641: 'portobello',
52203: 'remand',
19507: 'mummified',
27653: 'honk',
19508: 'spews',
40915: 'visitations',
52204: 'mummifies',
25253: 'cavanaugh',
23388: 'zeon',
40916: "jungle's",
34736: 'viertel',
27654: 'frenchmen',
52205: 'torpedoes',
52206: 'schlessinger',
34737: 'torpedoed',
69879: 'blister',
52207: 'cinefest',
34738: 'furlough',
52208: 'mainsequence',
40917: 'mentors',
9097: 'academic',
20605: 'stillness',
40918: 'academia',
52209: 'lonelier',
52210: 'nibby',
52211: "losers'",
40919: 'cineastes',
4452: 'corporate',
40920: 'massaging',
30596: 'bellow',
19509: 'absurdities',
53244: 'expetations',
40921: 'nyfiken',
75641: 'mehras',
52212: 'lasse',
52213: 'visability',
33949: 'militarily',
52214: "elder'",
19026: 'gainsbourg',
20606: 'hah',
13423: 'hai',
34739: 'haj',
25254: 'hak',
4314: 'hal',
4895: 'ham',
53262: 'duffer',
52216: 'haa',
69: 'had',
11933: 'advancement',
16828: 'hag',
25255: "hand'",
13424: 'hay',
20607: 'mcnamara',
52217: "mozart's",
30734: 'duffel',
30597: 'haq',
13890: 'har',
47: 'has',
2404: 'hat',
40922: 'hav',
30598: 'haw',
52218: 'figtings',
15498: 'elders',
52219: 'underpanted',
52220: 'pninson',
27655: 'unequivocally',
23676: "barbara's",
52222: "bello'",
13000: 'indicative',
40923: 'yawnfest',
52223: 'hexploitation',
52224: "loder's",
27656: 'sleuthing',
32625: "justin's",
52225: "'ball",
52226: "'summer",
34938: "'demons'",
52228: "mormon's",
34740: "laughton's",
52229: 'debell',
39727: 'shipyard',
30600: 'unabashedly',
40404: 'disks',
2293: 'crowd',
10090: 'crowe',
56437: "vancouver's",
34741: 'mosques',
6630: 'crown',
52230: 'culpas',
27657: 'crows',
53347: 'surrell',
52232: 'flowless',
52233: 'sheirk',
40926: "'three",
52234: "peterson'",
52235: 'ooverall',
40927: 'perchance',
1324: 'bottom',
53366: 'chabert',
52236: 'sneha',
13891: 'inhuman',
52237: 'ichii',
52238: 'ursla',
30601: 'completly',
40928: 'moviedom',
52239: 'raddick',
51998: 'brundage',
40929: 'brigades',
1184: 'starring',
52240: "'goal'",
52241: 'caskets',
52242: 'willcock',
52243: "threesome's",
52244: "mosque'",
52245: "cover's",
17640: 'spaceships',
40930: 'anomalous',
27658: 'ptsd',
52246: 'shirdan',
21965: 'obscenity',
30602: 'lemmings',
30603: 'duccio',
52247: "levene's",
52248: "'gorby'",
25258: "teenager's",
5343: 'marshall',
9098: 'honeymoon',
3234: 'shoots',
12261: 'despised',
52249: 'okabasho',
8292: 'fabric',
18518: 'cannavale',
3540: 'raped',
52250: "tutt's",
17641: 'grasping',
18519: 'despises',
40931: "thief's",
8929: 'rapes',
52251: 'raper',
27659: "eyre'",
52252: 'walchek',
23389: "elmo's",
40932: 'perfumes',
21921: 'spurting',
52253: "exposition'\x85",
52254: 'denoting',
34743: 'thesaurus',
40933: "shoot'",
49762: 'bonejack',
52256: 'simpsonian',
30604: 'hebetude',
34744: "hallow's",
52257: 'desperation\x85',
34745: 'incinerator',
10311: 'congratulations',
52258: 'humbled',
5927: "else's",
40848: 'trelkovski',
52259: "rape'",
59389: "'chapters'",
52260: '1600s',
7256: 'martian',
25259: 'nicest',
52262: 'eyred',
9460: 'passenger',
6044: 'disgrace',
52263: 'moderne',
5123: 'barrymore',
52264: 'yankovich',
40934: 'moderns',
52265: 'studliest',
52266: 'bedsheet',
14903: 'decapitation',
52267: 'slurring',
52268: "'nunsploitation'",
34746: "'character'",
9883: 'cambodia',
52269: 'rebelious',
27660: 'pasadena',
40935: 'crowne',
52270: "'bedchamber",
52271: 'conjectural',
52272: 'appologize',
52273: 'halfassing',
57819: 'paycheque',
20609: 'palms',
52274: "'islands",
40936: 'hawked',
21922: 'palme',
40937: 'conservatively',
64010: 'larp',
5561: 'palma',
21923: 'smelling',
13001: 'aragorn',
52275: 'hawker',
52276: 'hawkes',
3978: 'explosions',
8062: 'loren',
52277: "pyle's",
6707: 'shootout',
18520: "mike's",
52278: "driscoll's",
40938: 'cogsworth',
52279: "britian's",
34747: 'childs',
52280: "portrait's",
3629: 'chain',
2500: 'whoever',
52281: 'puttered',
52282: 'childe',
52283: 'maywether',
3039: 'chair',
52284: "rance's",
34748: 'machu',
4520: 'ballet',
34749: 'grapples',
76155: 'summerize',
30606: 'freelance',
52286: "andrea's",
52287: '\x91very',
45882: 'coolidge',
18521: 'mache',
52288: 'balled',
40940: 'grappled',
18522: 'macha',
21924: 'underlining',
5626: 'macho',
19510: 'oversight',
25260: 'machi',
11314: 'verbally',
21925: 'tenacious',
40941: 'windshields',
18560: 'paychecks',
3399: 'jerk',
11934: "good'",
34751: 'prancer',
21926: 'prances',
52289: 'olympus',
21927: 'lark',
10788: 'embark',
7368: 'gloomy',
52290: 'jehaan',
52291: 'turaqui',
20610: "child'",
2897: 'locked',
52292: 'pranced',
2591: 'exact',
52293: 'unattuned',
786: 'minute',
16121: 'skewed',
40943: 'hodgins',
34752: 'skewer',
52294: 'think\x85',
38768: 'rosenstein',
52295: 'helmit',
34753: 'wrestlemanias',
16829: 'hindered',
30607: "martha's",
52296: 'cheree',
52297: "pluckin'",
40944: 'ogles',
11935: 'heavyweight',
82193: 'aada',
11315: 'chopping',
61537: 'strongboy',
41345: 'hegemonic',
40945: 'adorns',
41349: 'xxth',
34754: 'nobuhiro',
52301: 'capitães',
52302: 'kavogianni',
13425: 'antwerp',
6541: 'celebrated',
52303: 'roarke',
40946: 'baggins',
31273: 'cheeseburgers',
52304: 'matras',
52305: "nineties'",
52306: "'craig'",
13002: 'celebrates',
3386: 'unintentionally',
14365: 'drafted',
52307: 'climby',
52308: '303',
18523: 'oldies',
9099: 'climbs',
9658: 'honour',
34755: 'plucking',
30077: '305',
5517: 'address',
40947: 'menjou',
42595: "'freak'",
19511: 'dwindling',
9461: 'benson',
52310: 'white’s',
40948: 'shamelessness',
21928: 'impacted',
52311: 'upatz',
3843: 'cusack',
37570: "flavia's",
52312: 'effette',
34756: 'influx',
52313: 'boooooooo',
52314: 'dimitrova',
13426: 'houseman',
25262: 'bigas',
52315: 'boylen',
52316: 'phillipenes',
40949: 'fakery',
27661: "grandpa's",
27662: 'darnell',
19512: 'undergone',
52318: 'handbags',
21929: 'perished',
37781: 'pooped',
27663: 'vigour',
3630: 'opposed',
52319: 'etude',
11802: "caine's",
52320: 'doozers',
34757: 'photojournals',
52321: 'perishes',
34758: 'constrains',
40951: 'migenes',
30608: 'consoled',
16830: 'alastair',
52322: 'wvs',
52323: 'ooooooh',
34759: 'approving',
40952: 'consoles',
52067: 'disparagement',
52325: 'futureistic',
52326: 'rebounding',
52327: "'date",
52328: 'gregoire',
21930: 'rutherford',
34760: 'americanised',
82199: 'novikov',
1045: 'following',
34761: 'munroe',
52329: "morita'",
52330: 'christenssen',
23109: 'oatmeal',
25263: 'fossey',
40953: 'livered',
13003: 'listens',
76167: "'marci",
52333: "otis's",
23390: 'thanking',
16022: 'maude',
34762: 'extensions',
52335: 'ameteurish',
52336: "commender's",
27664: 'agricultural',
4521: 'convincingly',
17642: 'fueled',
54017: 'mahattan',
40955: "paris's",
52339: 'vulkan',
52340: 'stapes',
52341: 'odysessy',
12262: 'harmon',
4255: 'surfing',
23497: 'halloran',
49583: 'unbelieveably',
52342: "'offed'",
30610: 'quadrant',
19513: 'inhabiting',
34763: 'nebbish',
40956: 'forebears',
34764: 'skirmish',
52343: 'ocassionally',
52344: "'resist",
21931: 'impactful',
52345: 'spicier',
40957: 'touristy',
52346: "'football'",
40958: 'webpage',
52348: 'exurbia',
52349: 'jucier',
14904: 'professors',
34765: 'structuring',
30611: 'jig',
40959: 'overlord',
25264: 'disconnect',
82204: 'sniffle',
40960: 'slimeball',
40961: 'jia',
16831: 'milked',
40962: 'banjoes',
1240: 'jim',
52351: 'workforces',
52352: 'jip',
52353: 'rotweiller',
34766: 'mundaneness',
52354: "'ninja'",
11043: "dead'",
40963: "cipriani's",
20611: 'modestly',
52355: "professor'",
40964: 'shacked',
34767: 'bashful',
23391: 'sorter',
16123: 'overpowering',
18524: 'workmanlike',
27665: 'henpecked',
18525: 'sorted',
52357: "jōb's",
52358: "'always",
34768: "'baptists",
52359: 'dreamcatchers',
52360: "'silence'",
21932: 'hickory',
52361: 'fun\x97yet',
52362: 'breakumentary',
15499: 'didn',
52363: 'didi',
52364: 'pealing',
40965: 'dispite',
25265: "italy's",
21933: 'instability',
6542: 'quarter',
12611: 'quartet',
52365: 'padmé',
52366: "'bleedmedry",
52367: 'pahalniuk',
52368: 'honduras',
10789: 'bursting',
41468: "pablo's",
52370: 'irremediably',
40966: 'presages',
57835: 'bowlegged',
65186: 'dalip',
6263: 'entering',
76175: 'newsradio',
54153: 'presaged',
27666: "giallo's",
40967: 'bouyant',
52371: 'amerterish',
18526: 'rajni',
30613: 'leeves',
34770: 'macauley',
615: 'seriously',
52372: 'sugercoma',
52373: 'grimstead',
52374: "'fairy'",
30614: 'zenda',
52375: "'twins'",
17643: 'realisation',
27667: 'highsmith',
7820: 'raunchy',
40968: 'incentives',
52377: 'flatson',
35100: 'snooker',
16832: 'crazies',
14905: 'crazier',
7097: 'grandma',
52378: 'napunsaktha',
30615: 'workmanship',
52379: 'reisner',
61309: "sanford's",
52380: '\x91doña',
6111: 'modest',
19156: "everything's",
40969: 'hamer',
52382: "couldn't'",
13004: 'quibble',
52383: 'socking',
21934: 'tingler',
52384: 'gutman',
40970: 'lachlan',
52385: 'tableaus',
52386: 'headbanger',
2850: 'spoken',
34771: 'cerebrally',
23493: "'road",
21935: 'tableaux',
40971: "proust's",
40972: 'periodical',
52388: "shoveller's",
25266: 'tamara',
17644: 'affords',
3252: 'concert',
87958: "yara's",
52389: 'someome',
8427: 'lingering',
41514: "abraham's",
34772: 'beesley',
34773: 'cherbourg',
28627: 'kagan',
9100: 'snatch',
9263: "miyazaki's",
25267: 'absorbs',
40973: "koltai's",
64030: 'tingled',
19514: 'crossroads',
16124: 'rehab',
52392: 'falworth',
52393: 'sequals',
...}Codepython
reverse_word_index.get(52393)Output
'sequals'Codepython
for i in range(20):
print(reverse_word_index.get(i))Output
None
None
None
None
the
and
a
of
to
is
br
in
it
i
this
that
was
as
for
with
Codepython
reverse_word_index[0] = "<PAD>"
reverse_word_index[1] = "<START>"
reverse_word_index[2] = "<UNK>"
reverse_word_index[3] = "<UNUSED>"
def decode_review(text):
return " ".join([reverse_word_index.get(i, "?") for i in text])
print(decode_review(train_data[10]))
Output
<START> french horror cinema has seen something of a revival over the last couple of years with great films such as inside and <UNK> romance <UNK> on to the scene <UNK> <UNK> the revival just slightly but stands head and shoulders over most modern horror titles and is surely one of the best french horror films ever made <UNK> was obviously shot on a low budget but this is made up for in far more ways than one by the originality of the film and this in turn is <UNK> by the excellent writing and acting that ensure the film is a winner the plot focuses on two main ideas prison and black magic the central character is a man named <UNK> sent to prison for fraud he is put in a cell with three others the quietly insane <UNK> body building <UNK> marcus and his retarded boyfriend daisy after a short while in the cell together they stumble upon a hiding place in the wall that contains an old <UNK> after <UNK> part of it they soon realise its magical powers and realise they may be able to use it to break through the prison walls br br black magic is a very interesting topic and i'm actually quite surprised that there aren't more films based on it as there's so much scope for things to do with it it's fair to say that <UNK> makes the best of it's <UNK> as despite it's <UNK> the film never actually feels restrained and manages to flow well throughout director eric <UNK> provides a great atmosphere for the film the fact that most of it takes place inside the central prison cell <UNK> that the film feels very claustrophobic and this immensely benefits the central idea of the prisoners wanting to use magic to break out of the cell it's very easy to get behind them it's often said that the unknown is the thing that really <UNK> people and this film proves that as the director <UNK> that we can never really be sure of exactly what is round the corner and this helps to ensure that <UNK> actually does manage to be quite frightening the film is memorable for a lot of reasons outside the central plot the characters are all very interesting in their own way and the fact that the book itself almost takes on its own character is very well done anyone worried that the film won't deliver by the end won't be disappointed either as the ending both makes sense and manages to be quite horrifying overall <UNK> is a truly great horror film and one of the best of the decade highly recommended viewing
Codepython
from tensorflow.keras.preprocessing.sequence import pad_sequences
max_length = 256
train_data = pad_sequences(
train_data,
value=0,
padding="post",
maxlen=max_length
)
test_data = pad_sequences(
test_data,
value=0,
padding="post",
maxlen=max_length
)Codepython
train_data[0]Output
array([ 1, 14, 22, 16, 43, 530, 973, 1622, 1385, 65, 458,
4468, 66, 3941, 4, 173, 36, 256, 5, 25, 100, 43,
838, 112, 50, 670, 2, 9, 35, 480, 284, 5, 150,
4, 172, 112, 167, 2, 336, 385, 39, 4, 172, 4536,
1111, 17, 546, 38, 13, 447, 4, 192, 50, 16, 6,
147, 2025, 19, 14, 22, 4, 1920, 4613, 469, 4, 22,
71, 87, 12, 16, 43, 530, 38, 76, 15, 13, 1247,
4, 22, 17, 515, 17, 12, 16, 626, 18, 2, 5,
62, 386, 12, 8, 316, 8, 106, 5, 4, 2223, 5244,
16, 480, 66, 3785, 33, 4, 130, 12, 16, 38, 619,
5, 25, 124, 51, 36, 135, 48, 25, 1415, 33, 6,
22, 12, 215, 28, 77, 52, 5, 14, 407, 16, 82,
2, 8, 4, 107, 117, 5952, 15, 256, 4, 2, 7,
3766, 5, 723, 36, 71, 43, 530, 476, 26, 400, 317,
46, 7, 4, 2, 1029, 13, 104, 88, 4, 381, 15,
297, 98, 32, 2071, 56, 26, 141, 6, 194, 7486, 18,
4, 226, 22, 21, 134, 476, 26, 480, 5, 144, 30,
5535, 18, 51, 36, 28, 224, 92, 25, 104, 4, 226,
65, 16, 38, 1334, 88, 12, 16, 283, 5, 16, 4472,
113, 103, 32, 15, 16, 5345, 19, 178, 32, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0], dtype=int32)Codepython
test_data[0]Output
array([ 1, 591, 202, 14, 31, 6, 717, 10, 10, 2, 2,
5, 4, 360, 7, 4, 177, 5760, 394, 354, 4, 123,
9, 1035, 1035, 1035, 10, 10, 13, 92, 124, 89, 488,
7944, 100, 28, 1668, 14, 31, 23, 27, 7479, 29, 220,
468, 8, 124, 14, 286, 170, 8, 157, 46, 5, 27,
239, 16, 179, 2, 38, 32, 25, 7944, 451, 202, 14,
6, 717, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0], dtype=int32)Codepython
import pandas as pd
pd.set_option('display.max_rows', 500)
pd.set_option('display.max_columns', 500)
pd.set_option('display.width', 1000)Codepython
decode_review(train_data[0])Output
"<START> this film was just brilliant casting location scenery story direction everyone's really suited the part they played and you could just imagine being there robert <UNK> is an amazing actor and now the same being director <UNK> father came from the same scottish island as myself so i loved the fact there was a real connection with this film the witty remarks throughout the film were great it was just brilliant so much that i bought the film as soon as it was released for <UNK> and would recommend it to everyone to watch and the fly fishing was amazing really cried at the end it was so sad and you know what they say if you cry at a film it must have been good and this definitely was also <UNK> to the two little boy's that played the <UNK> of norman and paul they were just brilliant children are often left out of the <UNK> list i think because the stars that play them all grown up are such a big profile for the whole film but these children are amazing and should be praised for what they have done don't you think the whole story was so lovely because it was true and was someone's life after all that was shared with us all <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD>"Codepython
pd.DataFrame(train_data)Output
0 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 \
0 1 14 22 16 43 530 973 1622 1385 65 458 4468 66 3941 4 173 36 256 5 25 100 43 838 112 50 670 2 9 35 480 284 5 150 4 172 112 167 2 336 385 39 4 172 4536 1111 17 546 38 13 447 4 192 50 16 6 147 2025 19 14 22 4 1920 4613 469 4 22 71 87 12 16 43 530 38 76 15 13 1247 4 22 17 515 17 12 16 626 18 2 5 62 386 12 8 316 8 106 5 4 2223 5244 16 480 66 3785 33 4 130 12 16 38 619 5 25 124 51 36 135 48 25 1415 33 6 22 12 215 28 77 52 5 14 407 16 82 2 8 4 107 117 5952 15 256 4 2 7 3766 5 723 36 71 43 530 476 26 400 317 46 7 4 2 1029 13 104 88 4 381 15 297 98 32 2071 56 26 141
1 1 194 1153 194 8255 78 228 5 6 1463 4369 5012 134 26 4 715 8 118 1634 14 394 20 13 119 954 189 102 5 207 110 3103 21 14 69 188 8 30 23 7 4 249 126 93 4 114 9 2300 1523 5 647 4 116 9 35 8163 4 229 9 340 1322 4 118 9 4 130 4901 19 4 1002 5 89 29 952 46 37 4 455 9 45 43 38 1543 1905 398 4 1649 26 6853 5 163 11 3215 2 4 1153 9 194 775 7 8255 2 349 2637 148 605 2 8003 15 123 125 68 2 6853 15 349 165 4362 98 5 4 228 9 43 2 1157 15 299 120 5 120 174 11 220 175 136 50 9 4373 228 8255 5 2 656 245 2350 5 4 9837 131 152 491 18 2 32 7464 1212 14 9 6 371 78 22 625 64 1382 9 8 168 145 23 4 1690
2 1 14 47 8 30 31 7 4 249 108 7 4 5974 54 61 369 13 71 149 14 22 112 4 2401 311 12 16 3711 33 75 43 1829 296 4 86 320 35 534 19 263 4821 1301 4 1873 33 89 78 12 66 16 4 360 7 4 58 316 334 11 4 1716 43 645 662 8 257 85 1200 42 1228 2578 83 68 3912 15 36 165 1539 278 36 69 2 780 8 106 14 6905 1338 18 6 22 12 215 28 610 40 6 87 326 23 2300 21 23 22 12 272 40 57 31 11 4 22 47 6 2307 51 9 170 23 595 116 595 1352 13 191 79 638 89 2 14 9 8 106 607 624 35 534 6 227 7 129 113 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3 1784 86 1117 8 3261 46 11 2 21 29 9 2841 23 4 1010 2 793 6 2 1386 1830 10 10 246 50 9 6 2750 1944 746 90 29 2 8 124 4 882 4 882 496 27 2 2213 537 121 127 1219 130 5 29 494 8 124 4 882 496 4 341 7 27 846 10 10 29 9 1906 8 97 6 236 2 1311 8 4 2 7 31 7 2 91 2 3987 70 4 882 30 579 42 9 12 32 11 537 10 10 11 14 65 44 537 75 2 1775 3353 2 1846 4 2 7 154 5 4 518 53 2 2 7 3211 882 11 399 38 75 257 3807 19 2 17 29 456 4 65 7 27 205 113 10 10 2 4 2 2 9 242 4 91 1202 2 5 2070 307 22 7 5168 126 93 40 2 13 188 1076 3222 19 4 2 7 2348 537 23 53 537 21
4 1 249 1323 7 61 113 10 10 13 1637 14 20 56 33 2401 18 457 88 13 2626 1400 45 3171 13 70 79 49 706 919 13 16 355 340 355 1696 96 143 4 22 32 289 7 61 369 71 2359 5 13 16 131 2073 249 114 249 229 249 20 13 28 126 110 13 473 8 569 61 419 56 429 6 1513 18 35 534 95 474 570 5 25 124 138 88 12 421 1543 52 725 6397 61 419 11 13 1571 15 1543 20 11 4 2 5 296 12 3524 5 15 421 128 74 233 334 207 126 224 12 562 298 2167 1272 7 2601 5 516 988 43 8 79 120 15 595 13 784 25 3171 18 165 170 143 19 14 5 7224 6 226 251 7 61 113 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
24995 1 14 9 6 2758 20 21 1517 7 2078 5 3129 86 58 143 12 4 1249 2 9 8 1152 23 2 1246 36 28 6 7877 6704 155 170 51 19 41 131 33 344 44 8 7466 39 312 396 5 90 5046 5 4562 145 1064 18 2867 8 81 142 333 58 143 25 923 89 2357 4 8827 658 9 2 34 41 369 11 4 9001 4322 1449 29 304 12 45 4 155 8 81 134 504 5 4 2778 561 4097 17 48 36 71 2 44 4 5825 11 15 172 136 4 8827 4322 613 9 6 147 3325 2 48 335 4 222 227 2728 5 40 15 243 7 228 41 239 764 40 4 1330 7 4 65 6 4322 65 19 4 52 493 112 84 7 1399 11 68 1427 11 9001 2 2086 32 4 428 3834 11 4 20 485 51 739 8 30 2012 4045 456 1183 64 18 231 5412 198
24996 2 12 11 27 322 637 43 482 15 45 5777 6919 5777 6919 16 32 4 3980 7 1168 3368 11 4 6583 25 70 184 76 482 4 360 39 133 10 10 50 26 6 378 73 66 53 74 6 378 21 637 64 901 44 107 7 712 15 13 28 19 14 20 31 9 4 96 4679 9 343 252 29 127 6 542 195 292 11 27 205 4792 432 7 96 5946 4 360 7 4 177 9 331 4366 21 8 28 90 3208 11 4 145 7 6 2 42 260 90 4836 83 4 668 2 4094 8 81 164 9 43 710 82 138 28 90 1559 5 42 516 175 8460 29 47 9 12 8 97 90 168 445 73 294 37 9 6556 2 7562 152 66 359 8 30 93 8 168 53 445 10 10 4 333 439 13 28 9 4 326 7 2 7562 138 7562 586 101 668 467 4 559
24997 1 11 6 230 245 6401 9 6 1225 446 2 45 2174 84 8322 4007 21 4 912 84 2 325 725 134 2 1715 84 5 36 28 57 1099 21 8 140 8 703 5 2 84 56 18 1644 14 9 31 7 4 9406 1209 2295 2 1008 18 6 20 207 110 563 12 8 2901 2 8 97 6 20 53 4767 74 4 460 364 1273 29 270 11 960 108 45 40 29 2961 395 11 6 4065 500 7 2 89 364 70 29 140 4 64 4780 11 4 2678 26 178 4 529 443 2 5 27 710 117 2 8123 165 47 84 37 131 818 14 595 10 10 61 1242 1209 10 10 288 2260 1702 34 2901 2 4 65 496 4 231 7 790 5 6 320 234 2766 234 1119 1574 7 496 4 139 929 2901 2 7750 5 4241 18 4 8497 2 250 11 1818 7561 4 4217 5408 747 1115
24998 1 1446 7079 69 72 3305 13 610 930 8 12 582 23 5 16 484 685 54 349 11 4120 2959 45 58 1466 13 197 12 16 43 23 2 5 62 30 145 402 11 4131 51 575 32 61 369 71 66 770 12 1054 75 100 2198 8 4 105 37 69 147 712 75 3543 44 257 390 5 69 263 514 105 50 286 1814 23 4 123 13 161 40 5 421 4 116 16 897 13 2 40 319 5872 112 6700 11 4803 121 25 70 3468 4 719 3798 13 18 31 62 40 8 7200 4 2 7 14 123 5 942 25 8 721 12 145 5 202 12 160 580 202 12 6 52 58 2 92 401 728 12 39 14 251 8 15 251 5 2 12 38 84 80 124 12 9 23 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24999 1 17 6 194 337 7 4 204 22 45 254 8 106 14 123 4 2 270 2 5 2 2 732 2098 101 405 39 14 1034 4 1310 9 115 50 305 12 47 4 168 5 235 7 38 111 699 102 7 4 4039 9245 9 24 6 78 1099 17 2345 2 21 27 9685 6139 5 2 1603 92 1183 4 1310 7 4 204 42 97 90 35 221 109 29 127 27 118 8 97 12 157 21 6789 2 9 6 66 78 1099 4 631 1191 5 2642 272 191 1070 6 7585 8 2197 2 2 544 5 383 1271 848 1468 2 497 2 8 1597 8778 2 21 60 27 239 9 43 8368 209 405 10 10 12 764 40 4 248 20 12 16 5 174 1791 72 7 51 6 1739 22 4 204 131 9 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
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
0 6 194 7486 18 4 226 22 21 134 476 26 480 5 144 30 5535 18 51 36 28 224 92 25 104 4 226 65 16 38 1334 88 12 16 283 5 16 4472 113 103 32 15 16 5345 19 178 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1 15 16 4 1355 5 28 6 52 154 462 33 89 78 285 16 145 95 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3 82 40 2 13 2 14 280 13 219 4 2 431 758 859 4 953 1052 2 7 5991 5 94 40 25 238 60 2 4 2 804 2 7 4 9941 132 8 67 6 22 15 9 283 8 5168 14 31 9 242 955 48 25 279 2 23 12 1685 195 25 238 60 796 2 4 671 7 2804 5 4 559 154 888 7 726 50 26 49 7008 15 566 30 579 21 64 2574
4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
24995 646 196 17 25 2537 12 17 1219 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24996 7 891 81 149 4679 140 143 134 2 8 79 27 1484 13 16 1578 7 4 3192 2 11 13 131 124 51 25 122 236 1506 11 257 420 50 62 977 8 30 35 3425 96 7 4471 129 5210 74 2 6 1573 1167 1347 15 5828 96 8 76 23 2331 46 7 129 1140 5946 35 4752 425 18 14 20 9 4 420 7 4 1012 7562 13 482 15 5902 2568 4 359 18 2
24997 372 1890 1006 541 9303 7 4 59 2 4 3586 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24998 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24999 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
[25000 rows x 256 columns]Codepython
import os
import tensorflow as tf
from tensorflow.keras.preprocessing.sequence import pad_sequences
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Embedding, Dense, GlobalAveragePooling1DCodepython
model = Sequential([
Embedding(input_dim=vocab_size, output_dim=16),
GlobalAveragePooling1D(),
Dense(16, activation="relu"),
Dense(1, activation="sigmoid")
])
model.compile(
optimizer="adam",
loss="binary_crossentropy",
metrics=["accuracy"]
)
model.summary()Output
Model: "sequential"
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
embedding (Embedding) (None, None, 16) 160000
global_average_pooling1d ( (None, 16) 0
GlobalAveragePooling1D)
dense (Dense) (None, 16) 272
dense_1 (Dense) (None, 1) 17
=================================================================
Total params: 160289 (626.13 KB)
Trainable params: 160289 (626.13 KB)
Non-trainable params: 0 (0.00 Byte)
_________________________________________________________________
2026-03-24 07:35:22.421361: I external/local_xla/xla/stream_executor/cuda/cuda_executor.cc:901] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero. See more at https://github.com/torvalds/linux/blob/v6.0/Documentation/ABI/testing/sysfs-bus-pci#L344-L355
2026-03-24 07:35:22.443247: I external/local_xla/xla/stream_executor/cuda/cuda_executor.cc:901] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero. See more at https://github.com/torvalds/linux/blob/v6.0/Documentation/ABI/testing/sysfs-bus-pci#L344-L355
2026-03-24 07:35:22.445513: I external/local_xla/xla/stream_executor/cuda/cuda_executor.cc:901] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero. See more at https://github.com/torvalds/linux/blob/v6.0/Documentation/ABI/testing/sysfs-bus-pci#L344-L355
2026-03-24 07:35:22.448504: I external/local_xla/xla/stream_executor/cuda/cuda_executor.cc:901] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero. See more at https://github.com/torvalds/linux/blob/v6.0/Documentation/ABI/testing/sysfs-bus-pci#L344-L355
2026-03-24 07:35:22.450665: I external/local_xla/xla/stream_executor/cuda/cuda_executor.cc:901] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero. See more at https://github.com/torvalds/linux/blob/v6.0/Documentation/ABI/testing/sysfs-bus-pci#L344-L355
2026-03-24 07:35:22.452839: I external/local_xla/xla/stream_executor/cuda/cuda_executor.cc:901] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero. See more at https://github.com/torvalds/linux/blob/v6.0/Documentation/ABI/testing/sysfs-bus-pci#L344-L355
2026-03-24 07:35:22.526681: I external/local_xla/xla/stream_executor/cuda/cuda_executor.cc:901] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero. See more at https://github.com/torvalds/linux/blob/v6.0/Documentation/ABI/testing/sysfs-bus-pci#L344-L355
2026-03-24 07:35:22.527572: I external/local_xla/xla/stream_executor/cuda/cuda_executor.cc:901] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero. See more at https://github.com/torvalds/linux/blob/v6.0/Documentation/ABI/testing/sysfs-bus-pci#L344-L355
2026-03-24 07:35:22.528338: I external/local_xla/xla/stream_executor/cuda/cuda_executor.cc:901] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero. See more at https://github.com/torvalds/linux/blob/v6.0/Documentation/ABI/testing/sysfs-bus-pci#L344-L355
2026-03-24 07:35:22.529114: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1929] Created device /job:localhost/replica:0/task:0/device:GPU:0 with 1195 MB memory: -> device: 0, name: NVIDIA GeForce RTX 3060, pci bus id: 0000:01:00.0, compute capability: 8.6
Codepython
history = model.fit(
train_data,
train_labels,
epochs=10,
batch_size=512,
validation_split=0.2
)
Output
Epoch 1/10
2026-03-24 07:35:23.352911: I external/local_xla/xla/service/service.cc:168] XLA service 0x7e1f55d59ca0 initialized for platform CUDA (this does not guarantee that XLA will be used). Devices:
2026-03-24 07:35:23.352929: I external/local_xla/xla/service/service.cc:176] StreamExecutor device (0): NVIDIA GeForce RTX 3060, Compute Capability 8.6
2026-03-24 07:35:23.356269: I tensorflow/compiler/mlir/tensorflow/utils/dump_mlir_util.cc:269] disabling MLIR crash reproducer, set env var `MLIR_CRASH_REPRODUCER_DIRECTORY` to enable.
2026-03-24 07:35:23.368272: I external/local_xla/xla/stream_executor/cuda/cuda_dnn.cc:454] Loaded cuDNN version 8900
WARNING: All log messages before absl::InitializeLog() is called are written to STDERR
I0000 00:00:1774337723.425238 1366164 device_compiler.h:186] Compiled cluster using XLA! This line is logged at most once for the lifetime of the process.
40/40 [==============================] - 4s 79ms/step - loss: 0.6913 - accuracy: 0.5541 - val_loss: 0.6879 - val_accuracy: 0.6628
Epoch 2/10
40/40 [==============================] - 3s 73ms/step - loss: 0.6818 - accuracy: 0.7006 - val_loss: 0.6720 - val_accuracy: 0.7418
Epoch 3/10
40/40 [==============================] - 2s 60ms/step - loss: 0.6588 - accuracy: 0.7554 - val_loss: 0.6402 - val_accuracy: 0.7740
Epoch 4/10
40/40 [==============================] - 2s 53ms/step - loss: 0.6187 - accuracy: 0.7872 - val_loss: 0.5941 - val_accuracy: 0.7938
Epoch 5/10
40/40 [==============================] - 2s 49ms/step - loss: 0.5656 - accuracy: 0.8146 - val_loss: 0.5401 - val_accuracy: 0.8136
Epoch 6/10
40/40 [==============================] - 2s 54ms/step - loss: 0.5067 - accuracy: 0.8408 - val_loss: 0.4869 - val_accuracy: 0.8274
Epoch 7/10
40/40 [==============================] - 1s 36ms/step - loss: 0.4502 - accuracy: 0.8576 - val_loss: 0.4405 - val_accuracy: 0.8442
Epoch 8/10
40/40 [==============================] - 1s 32ms/step - loss: 0.4019 - accuracy: 0.8693 - val_loss: 0.4035 - val_accuracy: 0.8590
Epoch 9/10
40/40 [==============================] - 2s 45ms/step - loss: 0.3629 - accuracy: 0.8795 - val_loss: 0.3751 - val_accuracy: 0.8614
Epoch 10/10
40/40 [==============================] - 1s 30ms/step - loss: 0.3317 - accuracy: 0.8891 - val_loss: 0.3538 - val_accuracy: 0.8668
Codepython
loss, accuracy = model.evaluate(test_data, test_labels)
print("Test Accuracy:", accuracy)Output
782/782 [==============================] - 1s 648us/step - loss: 0.3628 - accuracy: 0.8621
Test Accuracy: 0.8620799779891968
Codepython
import tensorflow as tf
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
from sklearn.metrics import confusion_matrix, classification_report
from tensorflow.keras.preprocessing.sequence import pad_sequences
Codepython
predictions = model.predict(test_data)
pred_labels = (predictions > 0.5).astype(int).flatten()
Output
782/782 [==============================] - 0s 455us/step
Codepython
print("\nClassification Report:\n")
print(classification_report(test_labels, pred_labels))
Output
Classification Report:
precision recall f1-score support
0 0.85 0.88 0.86 12500
1 0.87 0.85 0.86 12500
accuracy 0.86 25000
macro avg 0.86 0.86 0.86 25000
weighted avg 0.86 0.86 0.86 25000
Codepython
cm = confusion_matrix(test_labels, pred_labels)
plt.figure(figsize=(6,5))
sns.heatmap(
cm,
annot=True,
fmt="d",
cmap="Blues",
xticklabels=["Negative", "Positive"],
yticklabels=["Negative", "Positive"]
)
plt.title("Confusion Matrix")
plt.xlabel("Predicted")
plt.ylabel("Actual")
plt.show()Output
Codepython
plt.hist(predictions, bins=50)
plt.title("Prediction Confidence Distribution")
plt.xlabel("Probability of Positive Review")
plt.ylabel("Frequency")
plt.show()
Output
Codepython
word_index = tf.keras.datasets.imdb.get_word_index()
reverse_word_index = {value + 3: key for key, value in word_index.items()}
reverse_word_index[0] = "<PAD>"
reverse_word_index[1] = "<START>"
reverse_word_index[2] = "<UNK>"
reverse_word_index[3] = "<UNUSED>"
def decode_review(text):
return " ".join([reverse_word_index.get(i, "?") for i in text])
Codepython
misclassified = np.where(pred_labels != test_labels)[0]
print("\nTotal misclassified:", len(misclassified))
print("\nShowing 5 misclassified reviews:\n")
for i in misclassified[:5]:
print("Actual:", test_labels[i])
print("Predicted:", pred_labels[i])
print("Confidence:", predictions[i][0])
print("\nReview text:\n")
print(decode_review(test_data[i]))
print("\n" + "-"*80 + "\n")Output
Total misclassified: 3448
Showing 5 misclassified reviews:
Actual: 1
Predicted: 0
Confidence: 0.40321538
Review text:
<START> i'm absolutely disgusted this movie isn't being sold all who love this movie should email disney and increase the demand for it they'd eventually have to sell it then i'd buy copies for everybody i know everything and everybody in this movie did a good job and i haven't figured out why disney hasn't put this movie on dvd or on vhs in rental stores at least i haven't seen any copies this is a wicked good movie and should be seen by all the kids in the new generation don't get to see it and i think they should it should at least be put back on the channel this movie doesn't deserve a cheap <UNK> it deserves the real thing i'm them now this movie will be on dvd <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD>
--------------------------------------------------------------------------------
Actual: 0
Predicted: 1
Confidence: 0.81953204
Review text:
<START> hollywood had a long love affair with bogus <UNK> nights tales but few of these products have stood the test of time the most memorable were the jon hall maria <UNK> films which have long since become camp this one is filled with dubbed songs <UNK> <UNK> and slapstick it's a truly crop of corn and pretty near <UNK> today it was nominated for its imaginative special effects which are almost <UNK> in this day and age <UNK> mainly of trick photography the only outstanding positive feature which survives is its beautiful color and clarity sad to say of the many films made in this genre few of them come up to alexander <UNK> original thief of <UNK> almost any other <UNK> nights film is superior to this one though it's a loser <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD>
--------------------------------------------------------------------------------
Actual: 0
Predicted: 1
Confidence: 0.6651351
Review text:
<START> if you have never read the classic science fiction novel this mini series is based on it may actually be good unfortunately if you are a fan of the book you probably won't be able to watch more than the first hour or two all of the political intrigue has been taken out of the film the most important scenes from the book have been taken out characters motivations have been changed completely and words from the wrong characters mouths where in the novel paul was a teen age boy with incredible political skill and a great understanding of the way the world worked in this film he is hot headed and and frustrated avoid this movie at all costs <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD>
--------------------------------------------------------------------------------
Actual: 0
Predicted: 1
Confidence: 0.5873301
Review text:
<START> oh how awfully this movie is i don't know if it is a horror film or a drama cause the story and the both genres are not established very well the story is not moving it is slow boring and sleepy from the beginning to end this movie really <UNK> me but i really liked the camera work it is authentic fresh and clear the acting is great too the little boy was the great performer in this movie but it hasn't made me to jump from my seat but this movie makes me grab a <UNK> lay on the bed and sleep until the credits roll br br boring not worth watching i tell you this movie sucked br br 1 10 <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD>
--------------------------------------------------------------------------------
Actual: 1
Predicted: 0
Confidence: 0.48474506
Review text:
<START> alice is the kind of movie they made in the 30's and 40's never attempts to be an event just wants to entertain and it does i was surprised by <UNK> sutherland in a role that could be a cliche he made it real the plot does make <UNK> to alice in wonderland a guy dressed in white does go through a hole and <UNK> does fall down one like alice the plot does twist and turn but with a <UNK> you don't see in small movies i loved the direction sutherland just a very fast paced and interesting movie <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD> <PAD>
--------------------------------------------------------------------------------
Codepython
Lesson resources
Supporting code and files from this part of the curriculum.
Finished this lesson?
Keep your place here, or save it across devices with an email link.
Saved in this browser. Save progress with email →