imdb eda
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.
IMDB Sentiment Analysis - Exploratory Data Analysis (EDA)
This notebook focuses on understanding the IMDB dataset using TensorFlow's built‑in dataset.
We will:
- Load the dataset using TensorFlow
- Understand how reviews are encoded
- Decode reviews back into readable text
- Explore dataset size
- Analyze review length distribution
The model training and preprocessing pipeline are implemented in a separate Python script so the training process can run independently.
1. Import Libraries
import tensorflow as tf
import matplotlib.pyplot as plt
import numpy as np
WARNING: All log messages before absl::InitializeLog() is called are written to STDERR
I0000 00:00:1773040824.773500 179592 port.cc:153] 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`.
I0000 00:00:1773040824.807698 179592 cpu_feature_guard.cc:227] 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.
WARNING: All log messages before absl::InitializeLog() is called are written to STDERR
I0000 00:00:1773040825.652735 179592 port.cc:153] 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`.
2. Load IMDB Dataset using TensorFlow
TensorFlow provides a built‑in IMDB dataset where:
- Reviews are already converted to integer tokens
- Each number represents a word index
- Labels are:
0→ negative review1→ positive review
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))
Training samples: 25000
Test samples: 25000
3. Understanding Encoded Reviews
Each review is stored as a list of integers representing word indices.
print(train_data[0][:20])
[1, 14, 22, 16, 43, 530, 973, 1622, 1385, 65, 458, 4468, 66, 3941, 4, 173, 36, 256, 5, 25]
4. Decode Reviews Back to Text
TensorFlow provides a word index dictionary that maps words to numbers. We reverse this mapping to reconstruct readable reviews.
word_index = tf.keras.datasets.imdb.get_word_index()
word_index{'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,
...}reverse_word_index = {value + 3: key for key, value in word_index.items()}
reverse_word_index{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',
...}reverse_word_index.get(52393)'sequals'for i in range(20):
print(reverse_word_index.get(i))None
None
None
None
the
and
a
of
to
is
br
in
it
i
this
that
was
as
for
with
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[0]))
<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
5. Review Length Distribution
Understanding review length helps decide padding size for the model.
review_lengths = [len(x) for x in train_data]
plt.hist(review_lengths, bins=50)
plt.title("Review Length Distribution")
plt.xlabel("Length")
plt.ylabel("Frequency")
plt.show()
Most reviews fall within a certain length range, which helps us determine the maximum sequence length used during preprocessing in the training script.
Model training pre processing
import tensorflow as tf
from tensorflow.keras.preprocessing.sequence import pad_sequences
# -------------------------------
# 1. Load Dataset
# -------------------------------
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))
Training samples: 25000
Test samples: 25000
# -------------------------------
# 2. Preprocessing
# -------------------------------
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
)train_dataarray([[ 1, 14, 22, ..., 0, 0, 0],
[ 1, 194, 1153, ..., 0, 0, 0],
[ 1, 14, 47, ..., 0, 0, 0],
...,
[ 1, 11, 6, ..., 0, 0, 0],
[ 1, 1446, 7079, ..., 0, 0, 0],
[ 1, 17, 6, ..., 0, 0, 0]], dtype=int32)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 →